[Orxonox-commit 6937] r11558 - in code/branches/HUD_HS16/src/modules: overlays/hud pickup
patricwi at orxonox.net
patricwi at orxonox.net
Mon Nov 13 16:14:48 CET 2017
Author: patricwi
Date: 2017-11-13 16:14:47 +0100 (Mon, 13 Nov 2017)
New Revision: 11558
Modified:
code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc
code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h
code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc
Log:
no more segfaults but still not exiting properly - maybe never ending loop?
Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc 2017-11-13 15:13:43 UTC (rev 11557)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc 2017-11-13 15:14:47 UTC (rev 11558)
@@ -67,25 +67,35 @@
}
- void HUDPickupSystem::sync(std::vector<Pickupable*> p)
+ void HUDPickupSystem::sync(std::vector<Pickupable*> p, std::map<Pickupable*, uint32_t> indexes_)
{
//hide all pickup symbols in HUD and delete from local map
+
+ orxout() << "picks size before: " << picks.size() << endl;
+ orxout() << "p size before: " << p.size() << endl;
for(const auto& sm_pair : picks)
{
sm_pair.second->hideMe(sm_pair.first, repaint);
- picks.erase(sm_pair.first);
+ orxout() << "deleting local list picks: " << picks.size() << " pickup ptr" << sm_pair.first << endl;
}
+ picks.clear();
+ assert(picks.empty()); //picks must be empty now
+
//add to local map and place on screen
int i = 0;
const float offsetX = 0.345f;
float offsetY = 0.82f;
const float x = 0.102f;
+ orxout() << "picks size after: " << picks.size() << endl;
+ orxout() << "p size after: " << p.size() << endl;
+
for(Pickupable* pickup:p)
{
+ i=indexes_.find(pickup)->second;
//second row has offset
- if(i==4)
+ if(i==5)
{
i=0;
offsetY+=0.075f;
@@ -96,61 +106,10 @@
orxout() << "created new pickupHUDItem"<<endl;
item->setOverlayGroup(this->getOverlayGroup());
picks[pickup] = item;
- i++;
}
-
}
- void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_)
- {
- int i =0;
- const float offsetX = 0.345f;
- float offsetY = 0.82f;
- const float x = 0.102f;
-
- if(picks.size()>0)
- {
- for(Pickupable* p : picks)
- {
- i = indexes_.find(p)->second;
- offsetY = 0.82f;
-
- if(i>=5)
- {
- offsetY+=0.075f;
- i-=5;
- }
- if(this->picks.count(p)==0)
- {
- HUDPickupItem* item = new HUDPickupItem(this->getContext());
- item->initializeMaterial(this->getIcon(((Pickup*)p)->getRepresentationName()), offsetX+i*x, offsetY);
- orxout() << "created new pickupHUDItem"<<endl;
- item->setOverlayGroup(this->getOverlayGroup());
- this->picks[p] = item;
- }
- }
- }
- }
-
- void HUDPickupSystem::createPickupList()
- {
- }
-
- void HUDPickupSystem::removePickup(Pickupable* pickup)
- {
- assert(pickup);
- orxout()<< "removePickup called with " << pickup << endl;
- HUDPickupItem* item = this->picks.find(pickup)->second;
- orxout() << "removePickup: pickup= " << pickup << " item= " << item << endl;
- this->picks.erase(pickup);
- //assert(item);
- item->hideMe(pickup, repaint);
- orxout() << "i am hidden now" << endl;
- //assert(overlayElement_);
- //assert(this->background_);
- orxout()<< "end removePickup method" << endl;
- }
-
+
void HUDPickupSystem::destroyAll()
{
this->background_->removeChild(overlayElement_->getName());
Modified: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h 2017-11-13 15:13:43 UTC (rev 11557)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h 2017-11-13 15:14:47 UTC (rev 11558)
@@ -56,10 +56,7 @@
virtual ~HUDPickupSystem();
void sizeChanged();
- void sync(std::vector<Pickupable*> p);
- void updatePickupList(std::vector<Pickupable*> picks, std::map<Pickupable*, uint32_t> indexes_);
- void createPickupList();
- void removePickup(Pickupable* pickup);
+ void sync(std::vector<Pickupable*> p, std::map<Pickupable*, uint32_t> indexes_);
bool repaint=true; //if we shouldnt repaint, set this to false
Modified: code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc 2017-11-13 15:13:43 UTC (rev 11557)
+++ code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc 2017-11-13 15:14:47 UTC (rev 11558)
@@ -299,7 +299,7 @@
this->picks.push_back(pickup);
if(pickupSystem)
- pickupSystem->sync(picks);
+ pickupSystem->sync(picks, indexes_);
}
else // If it was dropped, it is removed from the required lists.
@@ -315,7 +315,7 @@
this->picks.erase(std::remove(this->picks.begin(), this->picks.end(), pickup), this->picks.end()); //remove pickup from vector
if(pickupSystem)
- pickupSystem->sync(picks);
+ pickupSystem->sync(picks, indexes_);
orxout() << "end of pickupChangedPickedUp" << endl;
}
More information about the Orxonox-commit
mailing list