(svn r12855) -Codechange: do not use autoptr's for testing whether certain objects can be build, but check it directly in the pool so we do not have to call destructors in the testing phase. Stations still use the autoptr though.

This commit is contained in:
rubidium
2008-04-23 20:56:08 +00:00
parent a204a3b70e
commit d56827a9a9
11 changed files with 60 additions and 79 deletions

View File

@@ -11,7 +11,6 @@
#include "saveload.h"
#include "command_func.h"
#include "variables.h"
#include "misc/autoptr.hpp"
#include "strings_func.h"
#include "viewport_func.h"
#include "zoom_func.h"
@@ -99,12 +98,11 @@ static void MarkSignDirty(Sign *si)
CommandCost CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
/* Try to locate a new sign */
Sign *si = new Sign(_current_player);
if (si == NULL) return_cmd_error(STR_2808_TOO_MANY_SIGNS);
AutoPtrT<Sign> s_auto_delete = si;
if (!Sign::CanAllocateItem()) return_cmd_error(STR_2808_TOO_MANY_SIGNS);
/* When we execute, really make the sign */
if (flags & DC_EXEC) {
Sign *si = new Sign(_current_player);
int x = TileX(tile) * TILE_SIZE;
int y = TileY(tile) * TILE_SIZE;
@@ -117,7 +115,6 @@ CommandCost CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
_sign_sort_dirty = true;
_new_sign_id = si->index;
_total_signs++;
s_auto_delete.Detach();
}
return CommandCost();