Mercurial > sumwars
changeset 12:5d7cea3f23f3
=neues netzwerk fertig, performancebesserungen
author | wuha |
---|---|
date | Wed, 01 Oct 2008 10:49:06 +0000 |
parents | 3dcd6f906783 |
children | 408853e127e9 |
files | src/core/action.cpp src/core/charconv.h src/core/creature.cpp src/core/debug.h src/core/document.cpp src/core/dropitem.cpp src/core/event.h src/core/gridunit.cpp src/core/gridunit.h src/core/item.cpp src/core/item.h src/core/itemfactory.cpp src/core/itemfactory.h src/core/itemlist.cpp src/core/objectfactory.h src/core/player.cpp src/core/player.h src/core/region.cpp src/core/region.h src/core/world.cpp src/gui/application.cpp src/gui/mainwindow.cpp src/gui/scene.cpp |
diffstat | 23 files changed, 556 insertions(+), 428 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/action.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/action.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -1710,11 +1710,6 @@ void Action::toString(CharConv* cv) { - /* - *((short*) buf) = (short) m_type; - *((float* ) (buf+sizeof(short))) = m_elapsed_time / m_time; - return buf+sizeof(short)+sizeof(float); - */ cv->toBuffer((short) m_type); cv->toBuffer(m_time); cv->toBuffer((char) m_action_equip);
--- a/src/core/charconv.h Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/charconv.h Wed Oct 01 10:49:06 2008 +0000 @@ -4,6 +4,7 @@ #include "raknet/BitStream.h" #include "raknet/GetTime.h" #include "raknet/MessageIdentifiers.h" +#include <algorithm> /** * \class CharConv @@ -139,9 +140,9 @@ return m_bitstream.GetNumberOfBitsUsed(); } - unsigned long getDelay() + float getDelay() { - return RakNet::GetTime()-m_timestamp; + return std::max(0.0f,static_cast<float>(RakNet::GetTime())-static_cast<float>(m_timestamp)); } unsigned long getTimestamp()
--- a/src/core/creature.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/creature.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -322,6 +322,7 @@ return; } + // Reziprokes des Ausfuehrungszeit float rezt = 1/m_action.m_time; @@ -348,7 +349,6 @@ dtime = m_action.m_time-m_action.m_elapsed_time; time -= dtime; finish = true; - } else { @@ -2255,6 +2255,16 @@ bool Creature::update (float time) { + Timer timer; + timer.start(); + + if (m_action.m_elapsed_time> m_action.m_time) + { + DEBUG("elapsed time %f all time %f",m_action.m_elapsed_time, m_action.m_time); + } + + float ptime = time; + // CreatureDynAttr* dynattr = getDynAttr(); DEBUG5("Update des Creatureobjekts [%i] wird gestartet", getId()); // interne Variable um Fehler zu speichern @@ -2361,7 +2371,6 @@ - // besondere zeitabhaengige Effekte berechnen if (getWorld()->isServer()) { @@ -2452,7 +2461,6 @@ } } - // Solange noch Zeit zur Verfügung steht Aktionen ausfuehren lassen while (time>0) { @@ -2486,7 +2494,13 @@ // Aktion ausfuehren performAction(time); - + + if (ptime < 1000 && time > 1000) + { + DEBUG("prev time %f time set to %f",ptime, time); + ptime = time; + } + } } @@ -2521,6 +2535,11 @@ } } + + if (timer.getTime()>10) + { + DEBUG("object %i update time %f",getId(), timer.getTime()); + } return result; } @@ -3525,7 +3544,7 @@ m_event_mask |= Event::DATA_STATUS_MODS; } - DEBUG("applying status mod %i for %f ms",i,t); + DEBUG5("applying status mod %i for %f ms",i,t); } } } @@ -4215,8 +4234,13 @@ bool newact= false; bool newmove = false; + float delay = cv->getDelay(); - + if (delay>1000) + { + DEBUG("got packet with delay %f %f",cv->getDelay(),delay); + } + if (event->m_data & Event::DATA_ACTION) { @@ -4352,7 +4376,7 @@ float goaltime = acttime; if (event->m_data & Event::DATA_ACTION) { - goaltime -= cv->getDelay(); + goaltime -= delay; } if (goaltime < 100) { @@ -4379,26 +4403,42 @@ if (newact) { - m_action.m_elapsed_time += cv->getDelay(); - if (!newmove && m_action.m_type != Action::NOACTION) + + m_action.m_elapsed_time += delay; + + + if (m_action.m_elapsed_time> m_action.m_time) { + // Aktion sollte schon beenden sein moveTo(newx,newy); + + m_action.m_type = Action::NOACTION; + m_action.m_elapsed_time =0; + } - - if (Action::getActionInfo(m_action.m_type)->m_distance != Action::SELF) + else { - float x = getGeometry()->m_shape.m_coordinate_x; - float y = getGeometry()->m_shape.m_coordinate_y; - float goalx = m_action.m_goal_coordinate_x; - float goaly = m_action.m_goal_coordinate_y; - - getGeometry()->m_angle = atan2(goaly-y,goalx-x); - - } - if (Action::getActionInfo(m_action.m_type)->m_base_action == Action::WALK) - { - getGeometry()->m_angle = atan2(getMoveInfo()->m_speed_y,getMoveInfo()->m_speed_x); - + + if (!newmove && m_action.m_type != Action::NOACTION) + { + moveTo(newx,newy); + } + + if (Action::getActionInfo(m_action.m_type)->m_distance != Action::SELF) + { + float x = getGeometry()->m_shape.m_coordinate_x; + float y = getGeometry()->m_shape.m_coordinate_y; + float goalx = m_action.m_goal_coordinate_x; + float goaly = m_action.m_goal_coordinate_y; + + getGeometry()->m_angle = atan2(goaly-y,goalx-x); + + } + if (Action::getActionInfo(m_action.m_type)->m_base_action == Action::WALK) + { + getGeometry()->m_angle = atan2(getMoveInfo()->m_speed_y,getMoveInfo()->m_speed_x); + + } } } }
--- a/src/core/debug.h Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/debug.h Wed Oct 01 10:49:06 2008 +0000 @@ -30,7 +30,7 @@ */ #include <stdio.h> -//#include "timer.h" +#include "timer.h" /** * \brief Gibt Informationen aus @@ -127,10 +127,10 @@ } -#ifdef WIN32 -#define gettext(text) text -#endif - +#ifdef WIN32 +#define gettext(text) text +#endif + #endif
--- a/src/core/document.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/document.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -403,7 +403,7 @@ m_gui_state.m_left_mouse_hold=false; m_gui_state.m_right_mouse_hold_time=0; - DEBUG("angeklickte Koordinaten: %f %f",x,y); + DEBUG5("angeklickte Koordinaten: %f %f",x,y); m_gui_state.m_clicked_object_id=0; command.m_id=0; @@ -742,7 +742,7 @@ if (aci->m_base_action== Action::NOACTION) return; - DEBUG("Setting Action %i",act); + DEBUG5("Setting Action %i",act); m_gui_state.m_left_mouse_hold = false; @@ -783,7 +783,7 @@ return; - DEBUG("Setting Action %i",act); + DEBUG5("Setting Action %i",act); m_gui_state.m_right_mouse_hold = false; ClientCommand command; @@ -914,7 +914,7 @@ } else if(dest == SHOW_CHATBOX) { - emitDebugSignal(3); + emitDebugSignal(1); } else if (dest == CLOSE_ALL) { @@ -953,6 +953,7 @@ if (m_world != 0) { m_world->update(time); + } DEBUG5("modified is %i",m_modified);
--- a/src/core/dropitem.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/dropitem.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -32,6 +32,6 @@ ostringstream out_stream; out_stream.str(""); - out_stream << m_item->getName() << ":" << getId(); + out_stream << m_item->getName() << ":" << m_item->m_id; return out_stream.str(); }
--- a/src/core/event.h Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/event.h Wed Oct 01 10:49:06 2008 +0000 @@ -81,7 +81,7 @@ * \brief ID des Objektes, das das Ereignis erzeugt hat */ int m_id; - + /** * \fn void toString(CharConv* cv) * \brief Konvertiert das Objekt in einen String und schreibt ihn in der Puffer
--- a/src/core/gridunit.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/gridunit.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -1,7 +1,6 @@ #include "gridunit.h" Gridunit::Gridunit() - : m_items() { DEBUG5("initialising Gridunit at %p",this); // Anzahl Objekte aller Sorten auf 0 setzen @@ -203,25 +202,6 @@ } -bool Gridunit::insertItem(DropItem* item) -{ - m_items.push_back(item); - return true; -} - -bool Gridunit::deleteItem(DropItem* item) -{ - list<DropItem*>::iterator it; - for (it = m_items.begin();it != m_items.end();++it) - { - if ((*it)==item) - { - m_items.erase(it); - return true; - } - } - return false; -} short& Gridunit::getObjectsNr(WorldObject::Group group) {
--- a/src/core/gridunit.h Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/gridunit.h Wed Oct 01 10:49:06 2008 +0000 @@ -3,6 +3,7 @@ #include "serverwobject.h" #include <list> +#include <map> #include "dropitem.h" #include "debug.h" @@ -55,11 +56,6 @@ */ short m_nr_creature; - /** - * \var list<DropItem*>* m_items - * \brief Liste der Items auf dem Feld - */ - list<DropItem*> m_items; public: @@ -141,28 +137,6 @@ */ bool moveObject(ServerWObject* object,WorldObject::Group group ); - /** - * \fn void insertItem(DropItem* item) - * \brief Fuegt Gegenstand ein - * \param item einzufuegender Gegenstand - */ - bool insertItem(DropItem* item); - - /** - * \fn void deleteItem(short x, short y) - * \brief Loescht einen Gegenstand aus dem Feld - * \param item zu loeschender Gegenstand - */ - bool deleteItem(DropItem* item); - - /** - * \fn list<DropItem*>* getItems() - * \brief Gibt die Liste der Items aus - */ - list<DropItem*>* getItems() - { - return &m_items; - } };
--- a/src/core/item.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/item.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -106,6 +106,7 @@ stmp[10] = '\0'; strncpy(stmp,m_subtype.c_str(),10); cv->toBuffer(stmp,10); + cv->toBuffer(m_id); }
--- a/src/core/item.h Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/item.h Wed Oct 01 10:49:06 2008 +0000 @@ -177,7 +177,7 @@ /** - * \fn Item(ItemBasicData& data) + * \fn Item(int id, ItemBasicData& data) * \brief erzeugt ein neuen Gegenstand mit den vorgegebenen Daten * \param data Daten auf deren Basis der Gegenstand erzeugt wird */ @@ -256,6 +256,11 @@ */ Subtype m_subtype; + /** + * \var int m_id + * \brief Id + */ + int m_id; /** * \var m_type;
--- a/src/core/itemfactory.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/itemfactory.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -11,13 +11,19 @@ map<Item::Subtype,ItemBasicData*> ItemFactory::m_item_data; +World* ItemFactory::m_world; + ItemFactory::ItemFactory() { } -Item* ItemFactory::createItem(Item::Type type, Item::Subtype subtype,float magic_power) +Item* ItemFactory::createItem(Item::Type type, Item::Subtype subtype, int id, float magic_power) { + if (id ==0) + { + id = m_world->getValidId(); + } DEBUG5("creating item %i / %s",type, subtype.c_str()); map<Item::Subtype,ItemBasicData*>::iterator it; it = m_item_data.find(subtype); @@ -30,6 +36,7 @@ DEBUG("found item data for subtype %s",subtype.c_str()); ItemBasicData* idata = it->second; item = new Item(*idata); + item->m_id = id; //createMagicMods(item,idata->m_modchance,magic_power, idata->m_min_enchant, idata->m_max_enchant); @@ -42,6 +49,7 @@ item = new Item; + item->m_id = id; item->m_type = type; item->m_subtype = subtype; @@ -185,26 +193,25 @@ item->m_equip_effect->m_dblock = 20; } - else if (type == Item::RING) - { - modchance[WILLPOWER_MOD]=0.2; - modchance[MAGIC_POWER_MOD]=0.25; - modchance[RESIST_FIRE_MOD]=0.10; - modchance[RESIST_ICE_MOD]=0.10; - modchance[RESIST_AIR_MOD]=0.10; - modchance[RESIST_ALL_MOD]=0.10; - modchance[DAMAGE_MULT_FIRE_MOD]=0.05; - modchance[DAMAGE_MULT_ICE_MOD]=0.05; - modchance[DAMAGE_MULT_AIR_MOD]=0.05; - } - else if (subtype =="ring") - { - min_enchant = min(200.0,magic_power*0.2); - max_enchant= min(850.0,magic_power*1.5); - item->m_price = 350; - item->m_size = Item::SMALL; - - } + + + } + else if (type == Item::RING) + { + modchance[WILLPOWER_MOD]=0.2; + modchance[MAGIC_POWER_MOD]=0.25; + modchance[RESIST_FIRE_MOD]=0.10; + modchance[RESIST_ICE_MOD]=0.10; + modchance[RESIST_AIR_MOD]=0.10; + modchance[RESIST_ALL_MOD]=0.10; + modchance[DAMAGE_MULT_FIRE_MOD]=0.05; + modchance[DAMAGE_MULT_ICE_MOD]=0.05; + modchance[DAMAGE_MULT_AIR_MOD]=0.05; + + min_enchant = min(200.0,magic_power*0.2); + max_enchant= min(850.0,magic_power*1.5); + item->m_price = 350; + item->m_size = Item::SMALL; } else if (type == Item::AMULET) { @@ -214,12 +221,10 @@ modchance[RESIST_ICE_MOD]=0.10; modchance[RESIST_AIR_MOD]=0.10; modchance[RESIST_ALL_MOD]=0.30; - if (subtype =="amulet") - { - min_enchant = min(200.0,magic_power*0.2); - max_enchant= min(850.0,magic_power*1.5); - item->m_size = Item::SMALL; - } + min_enchant = min(200.0,magic_power*0.2); + max_enchant= min(850.0,magic_power*1.5); + item->m_size = Item::SMALL; + } } else if (type == Item::WEAPON) @@ -756,7 +761,7 @@ if (size ==4) return 0; - DEBUG("item size: %i",size); + DEBUG5("item size: %i",size); Item* item =0; if (size == Item::GOLD) { @@ -815,17 +820,17 @@ Item::Subtype subtype= types[res]; Item::Type type = m_item_types.find(subtype)->second; - DEBUG("item type %i subtype %s",type,subtype.c_str()); + DEBUG5("item type %i subtype %s",type,subtype.c_str()); // Magiestaerke berechnen float magic =0; if (Random::random() < slot.m_magic_probability || type == Item::RING || type == Item::AMULET) { magic = Random::randrangef(slot.m_magic_power/4,slot.m_magic_power); - DEBUG("magic power %f",magic); + DEBUG5("magic power %f",magic); } - item = createItem(type,subtype,magic); + item = createItem(type,subtype,0,magic); return item; } return 0;
--- a/src/core/itemfactory.h Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/itemfactory.h Wed Oct 01 10:49:06 2008 +0000 @@ -10,6 +10,7 @@ using namespace std; +class World; /** @@ -57,13 +58,13 @@ ItemFactory(); /** - * \fn Item* createItem(Item::Type type, Item::Subtype subtype) + * \fn Item* createItem(Item::Type type, Item::Subtype subtype,int id=0,float magic_power =0) * \brief Erzeugt Objekt anhand zweier Parameter * \param type Typ des Items * \param subtype Untertyp des Items * \return Neues ServerItem */ - static Item* createItem(Item::Type type, Item::Subtype subtype, float magic_power =0); + static Item* createItem(Item::Type type, Item::Subtype subtype, int id=0, float magic_power =0); /** * \fn static void createMagicMods(Item* item, float* modchance, float magic_power, float min_enchant, float max_enchant) @@ -118,7 +119,7 @@ return Item::WEAPON; } } -*/ + */ private: /** @@ -138,10 +139,17 @@ * \brief enthaelt Basisdaten zu allen Items */ static map<Item::Subtype,ItemBasicData*> m_item_data; - - + + public: + + /** + * \var static World* m_world + * \brief Welt fuer die die Items generiert werden + */ + static World* m_world; }; +#include "world.h" #endif //ITEMFACTORY_H
--- a/src/core/itemlist.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/itemlist.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -440,6 +440,9 @@ return pos+BIG_ITEMS; } + ERRORMSG("unknown item size item type %i subtype %s",item->m_type,item->m_subtype.c_str()); + return NONE; + } int Equipement::getNumberItems(bool secondary_equip)
--- a/src/core/objectfactory.h Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/objectfactory.h Wed Oct 01 10:49:06 2008 +0000 @@ -33,7 +33,7 @@ /** * \var static World* m_world - * \brief Welt in fuer die die Objekte generiert werden + * \brief Welt fuer die die Objekte generiert werden */ static World* m_world;
--- a/src/core/player.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/player.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -624,18 +624,30 @@ short Player::insertItem(Item* itm) { + if (itm ==0) + ERRORMSG("tried to insert null item"); short pos = getEquipement()->insertItem(itm); - if (getWorld()->isServer()) + if (pos != Equipement::NONE) { - Event event; - event.m_type = Event::PLAYER_ITEM_PICKED_UP ; - event.m_data = pos; - event.m_id = getId(); - - DEBUG5("event: item picked up %i",pos); - - getWorld()->insertEvent(event); + // Gegenstand ins Inventar aufgenommen + if (getWorld()->isServer()) + { + Event event; + event.m_type = Event::PLAYER_ITEM_PICKED_UP ; + event.m_data = pos; + event.m_id = getId(); + + DEBUG("event: item picked up %i",pos); + + getWorld()->insertEvent(event); + } + } + else + { + // Gegenstand passt nicht ins Inventar + // wieder fallen lassen + getRegion()->dropItem(itm,getGeometry()->m_shape.m_coordinate_x,getGeometry()->m_shape.m_coordinate_y); } return pos; } @@ -884,53 +896,53 @@ } if (command->m_id==2) { - si = ItemFactory::createItem(Item::WEAPON,"short_sw",1000); + si = ItemFactory::createItem(Item::WEAPON,"short_sw",0,1000); getRegion()->dropItem(si,10,20); } if (command->m_id==1) { // Debugging 2 - si = ItemFactory::createItem(Item::WEAPON,"short_sw",1000); + si = ItemFactory::createItem(Item::WEAPON,"short_sw",0,1000); getEquipement()->swapItem(si,Equipement::MEDIUM_ITEMS+4); if (si!=0) delete si; - si = ItemFactory::createItem(Item::HELMET,"steel_hlm",100); + si = ItemFactory::createItem(Item::HELMET,"steel_hlm",0,100); getEquipement()->swapItem(si,Equipement::MEDIUM_ITEMS+5); if (si!=0) delete si; - si = ItemFactory::createItem(Item::GLOVES,"leath_gl",100); + si = ItemFactory::createItem(Item::GLOVES,"leath_gl",0,100); getEquipement()->swapItem(si,Equipement::MEDIUM_ITEMS+6); if (si!=0) delete si; - si = ItemFactory::createItem(Item::ARMOR,"heavy_arm",500); + si = ItemFactory::createItem(Item::ARMOR,"heavy_arm",0,500); getEquipement()->swapItem(si,Equipement::BIG_ITEMS+3); if (si!=0) delete si; - si = ItemFactory::createItem(Item::SHIELD,"iron_sh",100); + si = ItemFactory::createItem(Item::SHIELD,"iron_sh",0,100); getEquipement()->swapItem(si,Equipement::BIG_ITEMS+4); if (si!=0) delete si; - si = ItemFactory::createItem(Item::RING,"ring",100); + si = ItemFactory::createItem(Item::RING,"ring",0,100); getEquipement()->swapItem(si,Equipement::SMALL_ITEMS+15); if (si!=0) delete si; - si = ItemFactory::createItem(Item::RING,"ring",400); + si = ItemFactory::createItem(Item::RING,"ring",0,400); getEquipement()->swapItem(si,Equipement::SMALL_ITEMS+16); if (si!=0) delete si; - si = ItemFactory::createItem(Item::AMULET,"amulet",100); + si = ItemFactory::createItem(Item::AMULET,"amulet",0,100); getEquipement()->swapItem(si,Equipement::SMALL_ITEMS+17); if (si!=0) delete si; - si = ItemFactory::createItem(Item::AMULET,"amulet",800); + si = ItemFactory::createItem(Item::AMULET,"amulet",0,800); getEquipement()->swapItem(si,Equipement::SMALL_ITEMS+18); if (si!=0) delete si; @@ -1289,13 +1301,12 @@ if (itm !=0) { + // aus der Region entfernen + getRegion()->deleteItem(getCommand()->m_goal_object_id); + // Item einfuegen short pos = insertItem(itm); - if (pos != Equipement::NONE) - { - getRegion()->deleteItem(getCommand()->m_goal_object_id); - } } else { @@ -1741,15 +1752,17 @@ short pos; char type; char subtype[11]; + int id; subtype[10] ='\0'; Item* item; cv->fromBuffer<short>(pos); cv->fromBuffer<char>(type); cv->fromBuffer(subtype,10); + cv->fromBuffer(id); - item = ItemFactory::createItem((Item::Type) type, std::string(subtype)); + item = ItemFactory::createItem((Item::Type) type, std::string(subtype),id); item->fromString(cv); getEquipement()->swapItem(item,pos); @@ -1757,6 +1770,29 @@ delete item; } +void Player::readItemComplete(CharConv* cv) +{ + short pos; + char type; + char subtype[11]; + int id; + subtype[10] ='\0'; + Item* item; + + cv->fromBuffer<short>(pos); + cv->fromBuffer<char>(type); + cv->fromBuffer(subtype,10); + cv->fromBuffer(id); + + DEBUG("reading Item for pos %i type %i subtype %s",pos,type,subtype); + item = ItemFactory::createItem((Item::Type) type, std::string(subtype),id); + item->fromStringComplete(cv); + getEquipement()->swapItem(item,pos); + + if (item !=0) + delete item; +} + void Player::toStringComplete(CharConv* cv) { this->toString(cv);
--- a/src/core/player.h Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/player.h Wed Oct 01 10:49:06 2008 +0000 @@ -255,6 +255,12 @@ void readItem(CharConv* cv); /** + * \fn void readItem(CharConv* cv) + * \brief Liest ein Item mit allen Details aus dem Bitstream und fuegt es ins Inventar ein + */ + void readItemComplete(CharConv* cv); + + /** * \fn void writeEquipement(CharConv* cv) * \brief Schreibt des Inventar in den Puffer * \param buf Ausgabepuffer
--- a/src/core/region.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/region.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -23,6 +23,7 @@ // Liste der Gegenstaende m_drop_items = new map<int,DropItem*>; + m_drop_item_locations = new map<int,DropItem*>; m_id = id; @@ -67,6 +68,7 @@ delete m_data_grid; delete m_tiles; delete m_drop_items; + delete m_drop_item_locations; delete m_events; @@ -763,6 +765,7 @@ void Region::update(float time) { + DEBUG5("\nUpdate aller WeltObjekte starten\n"); //DEBUG("m_players %p",m_players); // Iterator zum durchmustern einer solchen Liste @@ -816,6 +819,7 @@ // Polymorpher Funktionsaufruf object->update(time); ++iter; + } } @@ -1030,33 +1034,34 @@ insertProjectile(proj,x,y); } -void Region::createItemFromString(CharConv* cv, int id) +void Region::createItemFromString(CharConv* cv) { char type; char subtype[11]; subtype[10] ='\0'; Item* item; + int id; + short sx,sy; + cv->fromBuffer(sx); + cv->fromBuffer(sy); cv->fromBuffer<char>(type); cv->fromBuffer(subtype,10); + cv->fromBuffer(id); - item = ItemFactory::createItem((Item::Type) type, std::string(subtype)); + item = ItemFactory::createItem((Item::Type) type, std::string(subtype),id); item->fromString(cv); - short sx = id / 10000; - short sy = id % 10000; - DropItem* di = new DropItem; di->m_item = item; di->m_x = sx; di->m_y = sy; - DEBUG("dropped item %i", sx*10000+sy); + DEBUG("dropped item %i at %i %i", id,sx,sy); di->m_time = 0; - Gridunit* gu = (m_data_grid->ind(sx/8,sy/8)); - - gu->insertItem(di); m_drop_items->insert(make_pair(id,di)); + m_drop_item_locations->insert(make_pair(sx*10000+sy,di)); + } @@ -1137,12 +1142,9 @@ cv->fromBuffer<short>(nr_items); DEBUG("items: %i",nr_items); // Gegenstaende einlesen - short sx,sy; for (int i=0; i<nr_items;i++) { - cv->fromBuffer(sx); - cv->fromBuffer(sy); - createItemFromString(cv, sx*10000+sy); + createItemFromString(cv); } @@ -1204,7 +1206,7 @@ } // Testen, ob dort nicht schon ein Item liegt - if (m_drop_items->find(i) == m_drop_items->end()) + if (m_drop_item_locations->find(i) == m_drop_item_locations->end()) { DEBUG5("field is free"); // Stelle ist frei @@ -1216,10 +1218,9 @@ DEBUG5("dropped item %i", sx*10000+sy); di->m_time = 0; - Gridunit* gu = (m_data_grid->ind(sx/8,sy/8)); + m_drop_items->insert(make_pair(di->m_item->m_id,di)); + m_drop_item_locations->insert(make_pair(i,di)); - gu->insertItem(di); - m_drop_items->insert(make_pair(i,di)); DEBUG5("items dropped at %i %i",sx,sy); @@ -1227,7 +1228,7 @@ { Event event; event.m_type = Event::ITEM_DROPPED; - event.m_id = i; + event.m_id = di->m_item->m_id; insertEvent(event); } @@ -1286,38 +1287,14 @@ } -bool Region::deleteItemAt(float x, float y) -{ - map<int,DropItem*>::iterator it; - short sx = (int) (x*2); - short sy = (int) (y*2); - it = m_drop_items->find((sx)*10000 + sy); - if (it == m_drop_items->end()) - { - return false; - } - else - { - Gridunit* gu = (m_data_grid->ind(sx/8,sy/8)); - // Gegenstand aus der Gridunit entfernen - gu->deleteItem(it->second); - // Item Wrapper loeschen - delete (it->second); - - m_drop_items->erase(it); - - return true; - } -} - Item* Region::getItemAt(float x, float y) { map<int,DropItem*>::iterator it; short sx = (int) (x*2); short sy = (int) (y*2); - int id = sx*10000 + sy; - DEBUG("searching ID %i", id); - it = m_drop_items->find(id); + int pos = sx*10000 + sy; + + it = m_drop_item_locations->find(pos); if (it == m_drop_items->end()) { return 0; @@ -1342,11 +1319,26 @@ } } -bool Region::deleteItem(int id) +DropItem* Region::getDropItem(int id) { map<int,DropItem*>::iterator it; - short sx = id /10000; - short sy = id%10000; + it = m_drop_items->find(id); + if (it == m_drop_items->end()) + { + return 0; + } + else + { + return it->second; + } +} + + +bool Region::deleteItem(int id, bool delitem) +{ + + map<int,DropItem*>::iterator it; + map<int,DropItem*>::iterator it2; it = m_drop_items->find(id); if (it == m_drop_items->end()) { @@ -1354,64 +1346,30 @@ } else { - Gridunit* gu = (m_data_grid->ind(sx/8,sy/8)); - // Gegenstand aus der Gridunit entfernen - gu->deleteItem(it->second); // Item Wrapper loeschen + int pos = 10000* it->second->m_x + it->second->m_y; + it2 = m_drop_item_locations->find(pos); + + Event event; + event.m_type = Event::ITEM_REMOVED; + event.m_id = it->second->m_item->m_id; + insertEvent(event); + + if (delitem) + { + delete it->second->m_item; + } delete (it->second); m_drop_items->erase(it); + m_drop_item_locations->erase(it2); - // Event einfuegen, dass das Item entfernt wurde - if (m_world->isServer()) - { - Event event; - event.m_type = Event::ITEM_REMOVED; - event.m_id = id; - - insertEvent(event); - } - DEBUG("item deleted %i",id); return true; } } -void Region::getItemsOnScreen(float center_x,float center_y, list<DropItem*>* result) -{ - // Grenzen des Bereichs in dem Items ausgegeben werden (in 4x4 Feldern) - int xmin = max(0,(int) floor(center_x/4-3)); - int ymin = max(0,(int) floor(center_y/4-3)); - int xmax = min(m_dimx-1,(int) ceil(center_x/4+3)); - int ymax = min(m_dimy-1,(int) ceil(center_y/4+3)); - - list<DropItem*>* lst; - list<DropItem*>::iterator it; - - DEBUG5("x %i %i y %i %i",xmin, xmax,ymin,ymax); - - int i,j; - Gridunit* gu; - // Schleifen ueber die betrachteten Gridunits - for (i=xmin; i<= xmax;i++) - { - for (j=ymin; j<= ymax; j++) - { - gu = m_data_grid->ind(i,j); - - // Schleife ueber die Items der Gridunit - lst = gu->getItems(); - for (it = lst->begin(); it != lst->end(); ++it) - { - result->push_back((*it)); - } - - } - } - -} -
--- a/src/core/region.h Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/region.h Wed Oct 01 10:49:06 2008 +0000 @@ -227,10 +227,10 @@ void createProjectileFromString(CharConv* cv); /** - * \fn void createItemFromString(CharConv* cv, int id) + * \fn void createItemFromString(CharConv* cv) * \brief liest die Daten zu einem Gegenstand aus dem Bitstream und erzeugt es */ - void createItemFromString(CharConv* cv, int id); + void createItemFromString(CharConv* cv); /** * \fn void deleteProjectile(DmgProjectile* proj) @@ -254,11 +254,6 @@ */ bool dropItem(Item* item, float x, float y); - /** - * \fn bool deleteItemAt(float x, float y) - * \brief Entfernt Item an der angegebenen Stelle aus der Region - */ - bool deleteItemAt(float x, float y); /** * \fn Item* getItemAt(float x, float y) @@ -267,10 +262,12 @@ Item* getItemAt(float x, float y); /** - * \fn bool deleteItem(int id) + * \fn bool deleteItem(int id, bool delitem) * \brief Entfernt Item aus der Region + * \param id ID des items + * \param delitem Wenn true, wird das Item geloescht, sonst nur aus der Region entfernt */ - bool deleteItem(int id); + bool deleteItem(int id, bool delitem=false); /** * \fn Item* getItem(int id) @@ -279,13 +276,10 @@ Item* getItem(int id); /** - * \fn void getItemsOnScreen(float center_x,float center_y, list<DropItem*>* result) - * \brief Fuegt alle Gegenstaende auf dem Bildschirm in die Liste eine - * \param center_x x-Koordinate Zentrum - * \param center_y y-Koordinate Zentrum - * \param result Liste in die die Objekte eingeordnet werden + * \fn Item* getDropItem(int id) + * \brief Gibt Item mit den Information wo es liegt aus. Gibt NULL aus, wenn dort kein Item ist */ - void getItemsOnScreen(float center_x,float center_y, list<DropItem*>* result); + DropItem* getDropItem(int id); /** * \fn void getRegionData(CharConv* cv) @@ -416,6 +410,13 @@ map<int,DropItem*>* m_drop_items; /** + * \var map<int,DropItem*>* m_drop_item_locations + * \brief Orte der Gegenstaende, die auf dem Boden liegen + */ + map<int,DropItem*>* m_drop_item_locations; + + + /** /* \var short m_id * \brief Nummer der Region */
--- a/src/core/world.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/core/world.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -66,6 +66,7 @@ // Items initialisieren ItemFactory::init(); + ItemFactory::m_world = this; ObjectFactory::init(); ObjectFactory::m_world = this; @@ -1153,9 +1154,10 @@ void World::update(float time) { + // Timer weiterzaehlen und Limits feststellen float timer_max[3]; - timer_max[0] = 200; timer_max[2] = 500; timer_max[3] = 1000; + timer_max[0] = 200; timer_max[1] = 500; timer_max[2] = 1000; for (int i=0; i<3; i++) { m_timer[i] += time; @@ -1167,7 +1169,6 @@ } } - DEBUG5("update %f",time); for (int i=0;i<WORLD_MAX_REGIONS;i++) { @@ -1176,8 +1177,8 @@ m_regions[i]->update(time); } } + // Durchmustern alle Handelsvorgänge - map<int,Trade*>::iterator iter2; Trade* trade=0; @@ -1235,6 +1236,8 @@ m_network->update(); + + } void World::updatePlayers() @@ -1314,6 +1317,10 @@ m_network->popSlotMessage( data ,slot); cv = new CharConv(data); + if (cv->getDelay()>1000) + { + DEBUG("got packet with delay %f",cv->getDelay()); + } headerp.fromString(cv); @@ -1472,7 +1479,10 @@ ret = processEvent(reg,cv); if (ret == false) + { break; + + } } } @@ -1489,7 +1499,6 @@ if (m_server) { // Nachrichten ueber die Events zur den Clients senden - short nr_events; Region* reg; list<Event>::iterator lt; for (it = m_player_slots->begin(); it != m_player_slots->end(); ++it) @@ -1500,30 +1509,30 @@ if (slot != LOCAL_SLOT) { // Anzahl der Events - nr_events = m_events->size(); + reg = pl->getRegion(); if (pl->getState() != WorldObject::STATE_ACTIVE && pl->getState() != WorldObject::STATE_DEAD && pl->getState() != WorldObject::STATE_DIEING) { reg =0; } - if (reg !=0) - { - nr_events += reg->getEvents()->size(); - } - - CharConv msg; + CharConv* msg; PackageHeader header; header.m_content = PTYPE_S2C_EVENT; - header.m_number =nr_events; + header.m_number =1; - header.toString(&msg); + // globale Events for (lt = m_events->begin(); lt != m_events->end(); ++lt) { + msg = new CharConv; DEBUG5(" send global event %i id %i",lt->m_type,lt->m_id); - writeEvent(reg,&(*lt),&msg); + + header.toString(msg); + writeEvent(reg,&(*lt),msg); + m_network->pushSlotMessage(msg->getBitStream(),slot); + delete msg; } // Events der Region in der der Spieler ist @@ -1531,11 +1540,17 @@ { for (lt = reg->getEvents()->begin(); lt != reg->getEvents()->end(); ++lt) { - writeEvent(reg,&(*lt),&msg); + msg = new CharConv; + + header.toString(msg); + writeEvent(reg,&(*lt),msg); + + m_network->pushSlotMessage(msg->getBitStream(),slot); + delete msg; } } - m_network->pushSlotMessage(msg.getBitStream(),slot); + } } @@ -1584,8 +1599,11 @@ if (event->m_type == Event::ITEM_DROPPED) { - item = region->getItem(event->m_id); - item->toString(cv); + DropItem* di; + di = region->getDropItem(event->m_id); + cv->toBuffer(di->m_x); + cv->toBuffer(di->m_y); + di->m_item->toString(cv); } } @@ -1599,11 +1617,25 @@ if (event->m_type == Event::PLAYER_ITEM_EQUIPED) { - DEBUG("send event: player equiped item"); object = (*m_players)[event->m_id]; cv->toBuffer<short>((short) event->m_data); static_cast<Player*>(object)->getEquipement()->getItem(event->m_data)->toString(cv); } + + if (event->m_type == Event::PLAYER_ITEM_PICKED_UP) + { + object = (*m_players)[event->m_id]; + cv->toBuffer<short>((short) event->m_data); + if (static_cast<Player*>(object)->getEquipement()->getItem(event->m_data) ==0) + ERRORMSG("no item at pos %i",event->m_data); + static_cast<Player*>(object)->getEquipement()->getItem(event->m_data)->toStringComplete(cv); + + } + + if (event->m_type == Event:: Event::ITEM_REMOVED) + { + DEBUG("removing item %i",event->m_id); + } } @@ -1612,155 +1644,191 @@ Event event; event.fromString(cv); + DEBUG5("got event %i id %i data %i",event.m_type, event.m_id, event.m_data); ServerWObject* object; DmgProjectile* proj; - if (event.m_type == Event::OBJECT_CREATED) - { - region->createObjectFromString(cv, m_players); - } - - if (event.m_type == Event::OBJECT_STAT_CHANGED) - { - object =region->getSWObject(event.m_id); - if (object !=0) - { - - object->processEvent(&event,cv); - } - else - { - // Event erhalten zu dem kein Objekt gehoert - DEBUG("object %i for event does not exist",event.m_id); - return false; - } - } - - if (event.m_type == Event::OBJECT_DESTROYED) - { - object =region->getSWObject(event.m_id); - if (object !=0) - { - object->destroy(); - region->deleteSWObject(object); - delete object; - } - else - { - // Event erhalten zu dem kein Objekt gehoert - } - } - - if (event.m_type == Event::PROJECTILE_CREATED) - { - region->createProjectileFromString(cv); - } - - if (event.m_type == Event::PROJECTILE_STAT_CHANGED) + switch(event.m_type) { - proj = region->getProjectile(event.m_id); - if (proj !=0) - { - proj->processEvent(&event,cv); - } - else - { - return false; - } - } + case Event::OBJECT_CREATED: + region->createObjectFromString(cv, m_players); + break; - if (event.m_type == Event::PROJECTILE_DESTROYED) - { - proj = region->getProjectile(event.m_id); - if (proj != 0) - { - region->deleteProjectile(proj); - delete proj; - } - - } - - if (event.m_type == Event::PLAYER_CHANGED_REGION) - { - if (m_players->count (event.m_id)>0) - { - object = (*m_players)[event.m_id]; + case Event::OBJECT_STAT_CHANGED: + object =region->getSWObject(event.m_id); + if (object !=0) + { - cv->fromBuffer(object->getGeometry()->m_shape.m_coordinate_x); - cv->fromBuffer(object->getGeometry()->m_shape.m_coordinate_y); - - // Lokaler Spieler wird schon vorher in die Region eingefuegt - if (object != m_local_player) + object->processEvent(&event,cv); + } + else { - insertPlayerIntoRegion(object,event.m_data); + // Event erhalten zu dem kein Objekt gehoert + DEBUG("object %i for event does not exist",event.m_id); + return false; } - } - } + break; - if (event.m_type == Event::PLAYER_QUIT) - { - if (m_players->count(event.m_id)>0) - { - object = (*m_players)[event.m_id]; - if (object != m_local_player) + + case Event::OBJECT_DESTROYED: + object =region->getSWObject(event.m_id); + if (object !=0) { - deleteSWObject(object); - m_players->erase( object->getId()); - - map<int,ServerWObject*>::iterator it; - for (it = m_player_slots->begin(); it != m_player_slots->end(); ++it) - { - if (it->second == object) - { - m_player_slots->erase(it); - break; - } - - } - + object->destroy(); + region->deleteSWObject(object); delete object; } - } - } - - if (event.m_type == Event::ITEM_DROPPED) - { - region->createItemFromString(cv,event.m_id); - } + else + { + // Event erhalten zu dem kein Objekt gehoert + } + break; - if (event.m_type == Event::ITEM_REMOVED) - { - region->deleteItem(event.m_id); - } + case Event::PROJECTILE_CREATED: + region->createProjectileFromString(cv); + break; + + case Event::PROJECTILE_STAT_CHANGED: + proj = region->getProjectile(event.m_id); + if (proj !=0) + { + proj->processEvent(&event,cv); + } + else + { + DEBUG("projectile %i for event does not exist",event.m_id); + return false; + } + break; + + case Event::PROJECTILE_DESTROYED: + proj = region->getProjectile(event.m_id); + if (proj != 0) + { + region->deleteProjectile(proj); + delete proj; + } + break; + - if (event.m_type == Event::PLAYER_NOITEM_EQUIPED) - { - if (m_players->count(event.m_id)>0) - { - object = (*m_players)[event.m_id]; - if (object != m_local_player) + case Event::PLAYER_CHANGED_REGION: + if (m_players->count (event.m_id)>0) + { + object = (*m_players)[event.m_id]; + + cv->fromBuffer(object->getGeometry()->m_shape.m_coordinate_x); + cv->fromBuffer(object->getGeometry()->m_shape.m_coordinate_y); + + // Lokaler Spieler wird schon vorher in die Region eingefuegt + if (object != m_local_player) + { + insertPlayerIntoRegion(object,event.m_data); + } + } + break; + + case Event::PLAYER_QUIT: + if (m_players->count(event.m_id)>0) { - Item* item =0; - static_cast<Player*>(object)->getEquipement()->swapItem(item,event.m_data); - - if (item !=0) - delete item; + object = (*m_players)[event.m_id]; + if (object != m_local_player) + { + deleteSWObject(object); + m_players->erase( object->getId()); + + map<int,ServerWObject*>::iterator it; + for (it = m_player_slots->begin(); it != m_player_slots->end(); ++it) + { + if (it->second == object) + { + m_player_slots->erase(it); + break; + } + + } + + delete object; + } } - } - } + break; + + case Event::ITEM_DROPPED: + region->createItemFromString(cv); + break; + + case Event::ITEM_REMOVED: + DEBUG("remove item %i",event.m_id); + region->deleteItem(event.m_id,true); + break; - if (event.m_type == Event::PLAYER_ITEM_EQUIPED) - { - if (m_players->count(event.m_id)>0) - { - object = (*m_players)[event.m_id]; - if (object != m_local_player) + case Event::PLAYER_NOITEM_EQUIPED: + + if (m_players->count(event.m_id)>0) + { + object = (*m_players)[event.m_id]; + if (object != m_local_player) + { + Item* item =0; + static_cast<Player*>(object)->getEquipement()->swapItem(item,event.m_data); + + if (item !=0) + delete item; + } + else + { + return false; + } + } + else + { + return false; + } + break; + + + case Event::PLAYER_ITEM_EQUIPED: + if (m_players->count(event.m_id)>0) { - static_cast<Player*>(object)->readItem(cv); + object = (*m_players)[event.m_id]; + if (object != m_local_player) + { + static_cast<Player*>(object)->readItem(cv); + } + else + { + return false; + } + } + else + { + return false; } - } + break; + + case Event::PLAYER_ITEM_PICKED_UP: + if (m_players->count(event.m_id)>0) + { + object = (*m_players)[event.m_id]; + if (object == m_local_player) + { + static_cast<Player*>(object)->readItemComplete(cv); + } + else + { + return false; + } + } + else + { + return false; + } + break; + + default: + ERRORMSG("unknown event type %i",event.m_type); + } return true;
--- a/src/gui/application.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/gui/application.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -117,6 +117,7 @@ int count=0; Ogre::Timer timer2; + timer.reset(); while (m_document->getState() != Document::SHUTDOWN) { @@ -124,7 +125,10 @@ ftime = ltime / ( 1000000.0); timer.reset(); - DEBUG5("overall frame time was %f",ftime*1000); + if (ftime*1000 >50) + { + DEBUG5("overall frame time was %f",ftime*1000); + } timer2.reset(); @@ -132,8 +136,10 @@ ltime =timer2.getMicroseconds (); time = ltime / ( 1000000.0); - - DEBUG5("update time was %f",time*1000); + if (time*1000 > 20) + { + DEBUG("update time was %f",time*1000); + } timer2.reset(); @@ -141,7 +147,10 @@ Ogre::WindowEventUtilities::messagePump(); ltime =timer2.getMicroseconds (); time = ltime / ( 1000000.0); - DEBUG5("message pump time was %f",time*1000); + if (time*1000>20) + { + DEBUG("message pump time was %f",time*1000); + } timer2.reset(); @@ -150,7 +159,10 @@ ltime =timer2.getMicroseconds (); time = ltime / ( 1000000.0); - DEBUG5("document update time was %f",time*1000); + if (time*1000 > 20) + { + DEBUG("document update time was %f",time*1000); + } /* count ++; @@ -174,17 +186,26 @@ ltime =timer2.getMicroseconds (); time = ltime / ( 1000000.0); - DEBUG5("view update time was %f",time*1000); + if (time*1000 > 20) + { + DEBUG("view update time was %f",time*1000); + } } catch (CEGUI::Exception e) { ERRORMSG("Error message: %s",e.getMessage().c_str()); } - + timer2.reset(); //DEBUG("frame time in s %f",time); m_cegui_system->injectTimePulse(ftime); - + + ltime =timer2.getMicroseconds (); + time = ltime / ( 1000000.0); + if (time*1000 > 20) + { + DEBUG("cegui update time was %f",time*1000); + } // rendern timer2.reset(); @@ -193,7 +214,10 @@ ltime =timer2.getMicroseconds (); time = ltime / ( 1000000.0); - DEBUG5("ogre frame time was %f",time*1000); + if (time*1000 > 50) + { + DEBUG("ogre frame time was %f",time*1000); + } } @@ -277,6 +301,11 @@ Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General"); Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Savegame"); Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("GUI"); + + Ogre::ResourceGroupManager::getSingleton().loadResourceGroup("General"); + Ogre::ResourceGroupManager::getSingleton().loadResourceGroup("Savegame"); + Ogre::ResourceGroupManager::getSingleton().loadResourceGroup("GUI"); + // Debugging: Meshes direkt anlegen
--- a/src/gui/mainwindow.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/gui/mainwindow.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -295,12 +295,9 @@ // Objekte aus dem Dokument darstellen if (m_document->getLocalPlayer()!=0) { - - + // Szene aktualisieren m_scene->update(); - - // ObjectInfo aktualisieren updateObjectInfo(); @@ -2845,7 +2842,7 @@ if (pos!=Action::NOACTION) { - DEBUG("update tooltip for %i", pos); + DEBUG5("update tooltip for %i", pos); CEGUI::WindowManager& win_mgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window* label; @@ -3033,6 +3030,8 @@ int id; stream >> id; string_stream<<name; + + DEBUG5("item hover id %i",id); Item* itm = player->getRegion()->getItem(id); @@ -3299,7 +3298,7 @@ if (we.button == CEGUI::LeftButton) { - DEBUG("left button pressed on skill %i",id); + DEBUG5("left button pressed on skill %i",id); if (m_document->getLocalPlayer()) { if (m_document->getLocalPlayer()->checkAbility((Action::ActionType) id)) @@ -3318,7 +3317,7 @@ if (we.button == CEGUI::RightButton) { - DEBUG("right button pressed on skill %i",id); + DEBUG5("right button pressed on skill %i",id); m_document->setRightAction((Action::ActionType) id); }
--- a/src/gui/scene.cpp Wed Oct 01 10:18:46 2008 +0000 +++ b/src/gui/scene.cpp Wed Oct 01 10:49:06 2008 +0000 @@ -238,7 +238,6 @@ // Kamera auf Spieler ausrichten m_camera->setPosition(Ogre::Vector3(x*50, 1000, y*50+300)); m_camera->lookAt(Ogre::Vector3(x*50,0,y*50)); - // alle Objekte aktualisieren updateObjects(); @@ -250,10 +249,14 @@ updateProjectiles(); + } void Scene::updateObjects() { + Timer timer; + timer.start(); + DEBUG5("update objects"); // Spielerobjekt Player* player = m_document->getLocalPlayer(); @@ -301,6 +304,7 @@ ++it2; } } + // aller Objekte im Dokument durchmustern for (it = objs.begin();it != objs.end(); ++it) @@ -309,6 +313,7 @@ // Darstellung fuer das Objekt aktualisieren updateObject(obj); } + } void Scene::updateItems() @@ -360,6 +365,18 @@ createItem(di,name); } + else + { + // Koordinaten des Objektes + float x=di->m_x; + float y=di->m_y; + + // Ortsvektor des Objektes + Ogre::Vector3 vec(x*25,0,y*25); + + // an die richtige Stelle verschieben + m_scene_manager->getSceneNode(node_name)->setPosition(vec); + } } } @@ -631,7 +648,7 @@ { std::string node_name = name + "Node"; - DEBUG("deleting object %s",name.c_str()); + DEBUG5("deleting object %s",name.c_str()); destroySceneNode(node_name); @@ -639,6 +656,9 @@ void Scene::createObject(WorldObject* obj,std::string& name, bool is_static) { + Timer timer; + timer.start(); + DEBUG5("creating object %s",name.c_str()); std::string node_name = name + "Node"; @@ -685,8 +705,6 @@ // eventuelle Partikeleffekte einfuegen - - if (!is_static) { // Partikelsysteme anhaengen @@ -741,7 +759,7 @@ Ogre::Vector3 vec(di->m_x*25,0,di->m_y*25); // in die Liste einfuegen - m_drop_items->insert(make_pair(di->getId(),name)); + m_drop_items->insert(make_pair(di->m_item->m_id,name)); // Node anlegen Ogre::SceneNode* obj_node;