Game Development Community

RTS Building Escape Bug

by Swaroop Reddy · in RTS Starter Kit · 10/27/2007 (9:53 am) · 9 replies

When we click on BUILD and then hit the esc key and exit without placing building the game exits to main menu but when the mission is loaded again the program shuts down.

I think the reason is that the function "startPlaceBuilding" is still running on exit and continues to run even when in main menu. There must be some way to close this function without placing the building when exiting.

#1
10/27/2007 (11:07 am)
Good catch Swaroop! Im kind of busy now, but with James we are scheduling a new patch for bug fixes, so maybe in some time we can fix this one.
#2
10/27/2007 (12:12 pm)
I found the fix if you want to include this. It is quite simple. The problem was a code variable not being reset on exit and with proper deletion of created object.

IN guiRTSTSCtrl.cc add the part between my coments

void GuiRTSTSCtrl::on3DMouseLeave(const Gui3DMouseEvent &)
{
//SMR add
if (!mPlacingBuilding || !mNewBuilding)
return;
Con::executef(this, 1, "deleteNewBuildObj");
mNewBuilding = NULL;
mPlacingBuilding = false;
//SMR add end
}

IN playGui.cs.cc add this function
function GuiRTSTSCtrl::deleteNewBuildObj(%this)
{
$NewBuilding.delete();
}
#3
10/27/2007 (1:30 pm)
Great Swaroop! we'll add this on the next patch.
#4
07/07/2008 (7:19 pm)
I am dealing with the same bug, just a little different. i need to be able to stop placing a building after the ghost building is attached to the cursor. should i modify the on3DRightMouseDown() function in guiRTSTSCtrl.cc ? i want the player to be able to right click the ghost building away.
#5
07/08/2008 (6:25 pm)
As a matter of fact that is exactly where i needed it
i put

if (mPlacingBuilding || mNewBuilding)
{
Con::executef(this, 1, "deleteNewBuildObj");
mNewBuilding = NULL;
mPlacingBuilding = false;
}

right at the top of the on3DRightMouseDown() function
#6
01/02/2009 (12:20 am)
I tried to implement what Joshua said above, However... Instead of being able to deselect the building with a right-click, It places a ghost building on the map.

Anyone know a fix for this?
#7
01/24/2009 (5:09 pm)
It appears to be working for me.

Make sure you've put in everything. Originally it wasn't working because I forgot to do this

Quote:IN playGui.cs.cc add this function
function GuiRTSTSCtrl::deleteNewBuildObj(%this)
{
$NewBuilding.delete();
}

Even if you are only using Joshua's code bit there and not Swaroop's(although I suggest you use both), you need to add that.
#8
01/17/2010 (11:49 pm)
I tried both but went with just using the right click option -- the on3DmouseLeave would cancel the build every time the cursor hit the GUI elements...
TGE + RTS kit 1.5.2
#9
01/17/2010 (11:51 pm)
Works, but the WORKER still moves to the right click location.

What would make it also clear the workers order? (ie. the right click to move?)