Closed kiwifb closed 1 year ago
I have a suspicion that taking the object out and lifting Heels in the process is not properly handled. But that's just a gut feeling at this point.
can’t see any other string copying within UserControlled::dropItem but this one
may it be that player.getDescriptionOfTakenItem() is not nil, but player.getDescriptionOfTakenItem()->getLabel() is nil ?
Commenting it out did not fix the issue. But I should have posted the terminal output with it.
took item "drum 1st"
free item "drum 1st" is to be gone
removing free item "drum 1st" from room "blacktooth27fish.xml"
drop item "drum"
creation of behavior "behavior of thing able to move by pushing" for free item "drum.cVhbtyvXsc1P" ( "drum" ) at x=52 y=143 z=24 with orientation "nowhere"
free item "drum 2nd" is yet in room "blacktooth27fish.xml"
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Aborted (core dumped)
So, we can see the line you quote is displaying without issue.
The last line before "terminate" is in https://github.com/dougmencken/HeadOverHeels/blob/321bcbd0aa9196adbb8631a49290f50d64eb2250/src/Room.cpp#L731
We do not get past that line
https://github.com/dougmencken/HeadOverHeels/blob/79a341e0df078709380f2f522e64b0c39eebc44e/src/behaviors/UserControlled.cpp#L512
and it is strange. player.placeItemInBag
? OK I get it, it is trying to reset the content of the bag to empty. But it is not working.
And if I comment the line, I get multiple copies of the object :) until it crashes because I go through the roof.
I was thinking that may be it did not like the nilPointer
in this line
https://github.com/dougmencken/HeadOverHeels/blob/79a341e0df078709380f2f522e64b0c39eebc44e/src/PlayerItem.cpp#L573
but it looks like we do not get there because it is trying and failing to cast the nilPointer
to const std::string&
when entering the method
https://github.com/dougmencken/HeadOverHeels/blob/79a341e0df078709380f2f522e64b0c39eebc44e/src/PlayerItem.cpp#L571
news from my side : with https://github.com/dougmencken/HeadOverHeels/commit/af1192edfef573e3c98a9605bd3f67a12b1dbd54 I finally got it to compile (with gcc 12.3.0 currently here on ubuntu), but it doesn't link pouring out with errors for each symbol
that's for plain default autoreconf -f -i && ./configure && make
currently I am pushing patches without really trying them, but it's blind, thus may I ask you how do you build it on Linux
I am currently building on kubuntu 22.04 which is gcc-11.4. I could try on my gentoo boxes (gcc-12.3.1 and gcc-13.2.0). I have installed liballegro5-dev and configure against that.
autoreconf -fi
./configure --prefix=/home/fbissey/Work/HeadOverHeels/_rootdir --with-allegro5 --enable-debug
make
make install
./_rootdir/bin/headoverheels
I can also build using the linux-build.sh
script, slightly patched
@@ -80,7 +80,7 @@ gameInstallPath="${buildFolder}"/_rootdir
if [ ! -f src/Makefile ]
then
- LDFLAGS="-L${allegro4installpath}/lib" \
+ LDFLAGS="-L${allegro4installpath}/lib -Wl,-rpath ${allegro4installpath}/lib" \
CFLAGS="-I${allegro4installpath}/include" \
CXXFLAGS="${CFLAGS}" \
./configure \
More controversially, I am using the following
diff --git a/configure.ac b/configure.ac
index 869f30f..eedcd9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,6 +84,7 @@ AM_CONDITIONAL([DARWIN], [test x"$on_darwin" = x"true"])
AC_OUTPUT( \
Makefile \
src/Makefile \
+ src/config_exe.h \
gamedata/Makefile \
gamedata/gfx/Makefile \
gamedata/gfx.2009/Makefile \
diff --git a/src/Ism.cpp b/src/Ism.cpp
index 93cb48f..109e74a 100644
--- a/src/Ism.cpp
+++ b/src/Ism.cpp
@@ -1,5 +1,6 @@
#include "Ism.hpp"
+#include "config_exe.h"
#include <algorithm>
@@ -115,7 +116,7 @@ void setPathToGame ( const char * pathToGame )
#if defined ( __CYGWIN__ )
FullPathToGame = "/bin/headoverheels" ;
#else
- FullPathToGame = "/usr/bin/headoverheels" ; /* hard-coded */
+ FullPathToGame = ConfigureExecutablePatch ; /* hard-coded */
/* for other paths like /usr/local
and~or custom names of game
it needs more sophiscated logic */
and src/config_exe.h.in
// Location of the executable of the game
#define ConfigureExecutablePatch "@prefix@/bin/headoverheels"
It needs a bit of work, because there are plenty of way that can break, but the game knows where to find its stuff without issues, so long as you do not use more exotic configure
flags like --bindir
.
The easy way to fix the bag emptying problem is to have a special function to empty the bag.
diff --git a/src/PlayerItem.cpp b/src/PlayerItem.cpp
index 93043e4..01b5c3c 100644
--- a/src/PlayerItem.cpp
+++ b/src/PlayerItem.cpp
@@ -575,6 +575,12 @@ void PlayerItem::placeItemInBag ( const std::string& labelOfItem, const std::str
this->behaviorOfTakenItem = behavior ;
}
+void PlayerItem::emptyBag ()
+{
+ this->descriptionOfTakenItem = nilPointer ;
+ this->behaviorOfTakenItem = "still" ;
+}
+
void PlayerItem::save ()
{
GameManager::getInstance().eatFish( *this, this->mediator->getRoom() );
diff --git a/src/PlayerItem.hpp b/src/PlayerItem.hpp
index 11727f6..3e78fcf 100644
--- a/src/PlayerItem.hpp
+++ b/src/PlayerItem.hpp
@@ -120,6 +120,8 @@ public:
void placeItemInBag ( const std::string & labelOfItem, const std::string & behavior ) ;
+ void emptyBag () ;
+
const DescriptionOfItem * getDescriptionOfTakenItem () const { return descriptionOfTakenItem ; }
const std::string & getBehaviorOfTakenItem () const { return this->behaviorOfTakenItem ; }
diff --git a/src/behaviors/UserControlled.cpp b/src/behaviors/UserControlled.cpp
index c22e3cc..6efe50b 100644
--- a/src/behaviors/UserControlled.cpp
+++ b/src/behaviors/UserControlled.cpp
@@ -509,7 +509,7 @@ void UserControlled::dropItem( PlayerItem & player )
GameManager::getInstance().emptyHandbag();
- player.placeItemInBag( nilPointer, "still" );
+ player.emptyBag();
// update activity
activity = ( activity == Activity::DropAndJump ? Activity::Jump : Activity::Wait );
Not elegant but it works.
Not elegant
emptyBag is much more elegant than placeInBag( nil ) imho, I really like your solution
I hope there're no any more nil references ;)
closing this?
Yes. I am moving on to some different issue. You should get a .gitignore
file, let me know if you'd like me to compose one.
So, now that I have the handbag I want to use it to get to the next room. But taking the item out of the bag crash the game. Full backtrace