Jump to content
  • Advertisement
Sign in to follow this  
zppz

Nested conditional expressions with concatenated strings - crash

This topic is 2150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

Apologies if this has already been brought up somewhere, but I found a crash in the scriptstdstring addon when attempting to use a concatenated string as part of a nested conditional expression. I am using Angelscript for the AI in an RTS game, and I had this to let the script show a label for the units:

string s = "Status: " + 
(
(m_actionState == AS_MOVETO) ? "moving" :
(m_actionState == AS_FIRE_AT_POINT) ? "firing at point" :
(m_actionState == AS_FIRE_AT_UNIT) ? "firing at unit" :
"idle"
)
+ "\n";

... and that worked fine, so I am assuming the problem is not with the nesting of conditional expressions per se.

 

Next I wanted to show the current speed of movement, so I changed the "moving" part to a concatenated string like this:

string s = "Status: " + 
(
(m_actionState == AS_MOVETO) ? ("moving"+10) :
(m_actionState == AS_FIRE_AT_POINT) ? "firing at point" :
(m_actionState == AS_FIRE_AT_UNIT) ? "firing at unit" :
"idle"
)
+ "\n";

...and this caused a crash in the CopyConstructString function. It appears that the 'other' parameter being given to the function is not a string. Obviously the literal 10 is not the value I really want to use, but after some experimentation I narrowed the problem down to the presence of the concatenation operator. It also crashed with concatenation of two strings.

 

If the branch of the conditional with the concatenation was never used (eg. no units ever entered the AS_MOVETO state), the program would run ok but random garbage characters would show for the text, and a crash would subsequently occur when releasing the asIScriptEngine object.

 

This is trivial to work around and is not causing me any real problems, but it seems pretty odd so I thought I would report it anyway.

 

 

Share this post


Link to post
Share on other sites
Advertisement

argh... apologies again. I was using 2.26.3 and the problem does not occur with 2.27.1 - thanks for all your hard work!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!