浏览代码

Code style: use parentheses for creating heap-based objects (#344)

ArseniyShestakov 8 年之前
父节点
当前提交
b52cfe5283

+ 1 - 1
AI/BattleAI/AttackPossibility.cpp

@@ -13,7 +13,7 @@
 int AttackPossibility::damageDiff() const
 {
 	if (!priorities)
-		priorities = new Priorities;
+		priorities = new Priorities();
 	const auto dealtDmgValue = priorities->stackEvaluator(enemy) * damageDealt;
 	const auto receivedDmgValue = priorities->stackEvaluator(attack.attacker) * damageReceived;
 	return dealtDmgValue - receivedDmgValue;

+ 1 - 1
client/CDefHandler.cpp

@@ -352,7 +352,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const SDL_Co
 
 CDefEssential * CDefHandler::essentialize()
 {
-	auto   ret = new CDefEssential;
+	auto ret = new CDefEssential();
 	ret->ourImages = ourImages;
 	notFreeImgs = true;
 	return ret;

+ 9 - 9
client/CMT.cpp

@@ -175,7 +175,7 @@ void init()
 	if(!settings["session"]["headless"].Bool())
 	{
 		pomtime.getDiff();
-		CCS->curh = new CCursorHandler;
+		CCS->curh = new CCursorHandler();
 		graphics = new Graphics(); // should be before curh->init()
 
 		CCS->curh->initCursor();
@@ -313,7 +313,7 @@ int main(int argc, char** argv)
 	// Init old logging system and new (temporary) logging system
 	CStopWatch total, pomtime;
 	std::cout.flags(std::ios::unitbuf);
-	console = new CConsoleHandler;
+	console = new CConsoleHandler();
 	*console->cb = processCommand;
 	console->start();
 
@@ -456,25 +456,25 @@ int main(int argc, char** argv)
 		logGlobal->infoStream() <<"\tInitializing screen: "<<pomtime.getDiff();
 	}
 
-	CCS = new CClientState;
-	CGI = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler etc.)
+	CCS = new CClientState();
+	CGI = new CGameInfo(); //contains all global informations about game (texts, lodHandlers, map handler etc.)
 	// Initialize video
 #ifdef DISABLE_VIDEO
-	CCS->videoh = new CEmptyVideoPlayer;
+	CCS->videoh = new CEmptyVideoPlayer();
 #else
 	if (!settings["session"]["headless"].Bool() && !vm.count("disable-video"))
-		CCS->videoh = new CVideoPlayer;
+		CCS->videoh = new CVideoPlayer();
 	else
-		CCS->videoh = new CEmptyVideoPlayer;
+		CCS->videoh = new CEmptyVideoPlayer();
 #endif
 
 	logGlobal->infoStream()<<"\tInitializing video: "<<pomtime.getDiff();
 
 	//initializing audio
-	CCS->soundh = new CSoundHandler;
+	CCS->soundh = new CSoundHandler();
 	CCS->soundh->init();
 	CCS->soundh->setVolume(settings["general"]["sound"].Float());
-	CCS->musich = new CMusicHandler;
+	CCS->musich = new CMusicHandler();
 	CCS->musich->init();
 	CCS->musich->setVolume(settings["general"]["music"].Float());
 	logGlobal->infoStream()<<"Initializing screen and sound handling: "<<pomtime.getDiff();

+ 1 - 1
client/CPlayerInterface.cpp

@@ -124,7 +124,7 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player)
 	battleInt = nullptr;
 	makingTurn = false;
 	showingDialog = new CondSh<bool>(false);
-	cingconsole = new CInGameConsole;
+	cingconsole = new CInGameConsole();
 	GH.terminate_cond.set(false);
 	firstCall = 1; //if loading will be overwritten in serialize
 	autosaveCount = 0;

+ 3 - 3
client/CPreGame.cpp

@@ -190,7 +190,7 @@ public:
 	virtual ~CBaseForPGApply(){};
 	template<typename U> static CBaseForPGApply *getApplier(const U * t=nullptr)
 	{
-		return new CApplyOnPG<U>;
+		return new CApplyOnPG<U>();
 	}
 };
 
@@ -573,7 +573,7 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EGameM
 	CServerHandler *sh = nullptr;
 	if(isHost())
 	{
-		sh = new CServerHandler;
+		sh = new CServerHandler();
 		sh->startServer();
 	}
 
@@ -722,7 +722,7 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EGameM
 			*serv << &uso;
 		}
 
-		applier = new CApplier<CBaseForPGApply>;
+		applier = new CApplier<CBaseForPGApply>();
 		registerTypesPregamePacks(*applier);
 		serverHandlingThread = new boost::thread(&CSelectionScreen::handleConnection, this);
 	}

+ 2 - 2
client/Client.cpp

@@ -71,7 +71,7 @@ public:
 
 	template<typename U> static CBaseForCLApply *getApplier(const U * t=nullptr)
 	{
-		return new CApplyOnCL<U>;
+		return new CApplyOnCL<U>();
 	}
 };
 
@@ -117,7 +117,7 @@ void CClient::init()
 		connectionHandler.reset();
 	}
 	pathInfo = nullptr;
-	applier = new CApplier<CBaseForCLApply>;
+	applier = new CApplier<CBaseForCLApply>();
 	registerTypesClientPacks1(*applier);
 	registerTypesClientPacks2(*applier);
 	IObjectInterface::cb = this;

+ 1 - 1
client/battle/CBattleInterface.cpp

@@ -1383,7 +1383,7 @@ CBattleInterface::PossibleActions CBattleInterface::getCasterAction(const CSpell
 
 void CBattleInterface::castThisSpell(SpellID spellID)
 {
-	auto  ba = new BattleAction;
+	auto ba = new BattleAction();
 	ba->actionType = Battle::HERO_SPELL;
 	ba->additionalInfo = spellID; //spell number
 	ba->destinationTile = -1;

+ 2 - 2
client/windows/CAdvmapInterface.cpp

@@ -715,7 +715,7 @@ CAdvMapInt::~CAdvMapInt()
 
 void CAdvMapInt::fshowOverview()
 {
-	GH.pushInt(new CKingdomInterface);
+	GH.pushInt(new CKingdomInterface());
 }
 
 void CAdvMapInt::fworldViewBack()
@@ -808,7 +808,7 @@ void CAdvMapInt::fshowSpellbok()
 
 void CAdvMapInt::fadventureOPtions()
 {
-	GH.pushInt(new CAdventureOptions);
+	GH.pushInt(new CAdventureOptions());
 }
 
 void CAdvMapInt::fsystemOptions()

+ 3 - 3
client/windows/CCastleInterface.cpp

@@ -1323,7 +1323,7 @@ CHallInterface::CHallInterface(const CGTownInstance *Town):
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 
-	resdatabar = new CMinorResDataBar;
+	resdatabar = new CMinorResDataBar();
 	resdatabar->pos.x += pos.x;
 	resdatabar->pos.y += pos.y;
 	Rect barRect(5, 556, 740, 18);
@@ -1498,7 +1498,7 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
 		recAreas.push_back(new RecruitArea(positions[i].x, positions[i].y, town, i));
 	}
 
-	resdatabar = new CMinorResDataBar;
+	resdatabar = new CMinorResDataBar();
 	resdatabar->pos.x += pos.x;
 	resdatabar->pos.y += pos.y;
 
@@ -1671,7 +1671,7 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner,std::string imagem)
 
 	window = new CPicture(owner->town->town->clientInfo.guildWindow , 332, 76);
 
-	resdatabar = new CMinorResDataBar;
+	resdatabar = new CMinorResDataBar();
 	resdatabar->pos.x += pos.x;
 	resdatabar->pos.y += pos.y;
 	Rect barRect(7, 556, 737, 18);

+ 2 - 2
client/windows/CHeroWindow.cpp

@@ -40,7 +40,7 @@
 
 const TBonusListPtr CHeroWithMaybePickedArtifact::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root, const std::string & cachingStr) const
 {
-	TBonusListPtr out(new BonusList);
+	TBonusListPtr out(new BonusList());
 	TBonusListPtr heroBonuses = hero->getAllBonuses(selector, limit, hero);
 	TBonusListPtr bonusesFromPickedUpArtifact;
 
@@ -50,7 +50,7 @@ const TBonusListPtr CHeroWithMaybePickedArtifact::getAllBonuses(const CSelector
 		bonusesFromPickedUpArtifact = cp->src.art->getAllBonuses(selector, limit, hero);
 	}
 	else
-		bonusesFromPickedUpArtifact = TBonusListPtr(new BonusList);
+		bonusesFromPickedUpArtifact = TBonusListPtr(new BonusList());
 
 	for(auto b : *bonusesFromPickedUpArtifact)
 		*heroBonuses -= b;

+ 5 - 5
client/windows/CKingdomInterface.cpp

@@ -73,7 +73,7 @@ InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data)
 	if (value)
 		pos = pos | value->pos;
 
-	hover = new CHoverableArea;
+	hover = new CHoverableArea();
 	hover->hoverText = data->getHoverText();
 	hover->pos = pos;
 }
@@ -599,7 +599,7 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
 
 		minesBox[i]->removeUsedEvents(LCLICK|RCLICK); //fixes #890 - mines boxes ignore clicks
 	}
-	incomeArea = new CHoverableArea;
+	incomeArea = new CHoverableArea();
 	incomeArea->pos = Rect(pos.x+580, pos.y+31+footerPos, 136, 68);
 	incomeArea->hoverText = CGI->generaltexth->allTexts[255];
 	incomeAmount = new CLabel(628, footerPos + 70, FONT_SMALL, TOPLEFT, Colors::WHITE, boost::lexical_cast<std::string>(totalIncome));
@@ -866,9 +866,9 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero):
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 
 	artTabs.resize(3);
-	auto   arts1 = new ArtSlotsTab;
-	auto   arts2 = new ArtSlotsTab;
-	auto   backpack = new BackpackTab;
+	auto arts1 = new ArtSlotsTab();
+	auto arts2 = new ArtSlotsTab();
+	auto backpack = new BackpackTab();
 	artTabs[0] = arts1;
 	artTabs[1] = arts2;
 	artTabs[2] = backpack;

+ 1 - 1
client/windows/CWindowObject.cpp

@@ -215,7 +215,7 @@ void CWindowObject::setShadow(bool on)
 		blitAlphaRow(shadowRight, 0);
 
 		//generate "shadow" object with these 3 pieces in it
-		shadow = new CIntObject;
+		shadow = new CIntObject();
 		shadow->addChild(new CPicture(shadowCorner, shadowPos.x, shadowPos.y));
 		shadow->addChild(new CPicture(shadowRight,  shadowPos.x, shadowStart.y));
 		shadow->addChild(new CPicture(shadowBottom, shadowStart.x, shadowPos.y));

+ 1 - 1
launcher/mainwindow_moc.cpp

@@ -21,7 +21,7 @@
 
 void MainWindow::load()
 {
-	console = new CConsoleHandler;
+	console = new CConsoleHandler();
 	CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() / "VCMI_Launcher_log.txt", console);
 	logConfig.configureDefault();
 

+ 7 - 7
lib/CGameState.cpp

@@ -55,7 +55,7 @@ public:
 	virtual ~CBaseForGSApply(){};
 	template<typename U> static CBaseForGSApply *getApplier(const U * t=nullptr)
 	{
-		return new CApplyOnGS<U>;
+		return new CApplyOnGS<U>();
 	}
 };
 
@@ -295,10 +295,10 @@ static CGObjectInstance * createObject(Obj id, int subid, int3 pos, PlayerColor
 			break;
 		}
 	case Obj::TOWN:
-		nobj = new CGTownInstance;
+		nobj = new CGTownInstance();
 		break;
 	default: //rest of objects
-		nobj = new CGObjectInstance;
+		nobj = new CGObjectInstance();
 		break;
 	}
 	nobj->ID = id;
@@ -679,10 +679,10 @@ int CGameState::getDate(Date::EDateType mode) const
 CGameState::CGameState()
 {
 	gs = this;
-	applierGs = new CApplier<CBaseForGSApply>;
+	applierGs = new CApplier<CBaseForGSApply>();
 	registerTypesClientPacks1(*applierGs);
 	registerTypesClientPacks2(*applierGs);
-	//objCaller = new CObjectCallersHandler;
+	//objCaller = new CObjectCallersHandler();
 	globalEffects.setDescription("Global effects");
 	globalEffects.setNodeType(CBonusSystemNode::GLOBAL_EFFECTS);
 	day = 0;
@@ -2968,7 +2968,7 @@ void InfoAboutHero::initFromHero(const CGHeroInstance *h, InfoAboutHero::EInfoLe
 	if(detailed)
 	{
 		//include details about hero
-		details = new Details;
+		details = new Details();
 		details->luck = h->LuckVal();
 		details->morale = h->MoraleVal();
 		details->mana = h->mana;
@@ -3022,7 +3022,7 @@ void InfoAboutTown::initFromTown(const CGTownInstance *t, bool detailed)
 	if(detailed)
 	{
 		//include details about hero
-		details = new Details;
+		details = new Details();
 		TResources income = t->dailyIncome();
 		details->goldIncome = income[Res::GOLD];
 		details->customRes = t->hasBuilt(BuildingID::RESOURCE_SILO);

+ 2 - 2
lib/CGeneralTextHandler.cpp

@@ -269,8 +269,8 @@ float CLegacyConfigParser::readNumber()
 
 	std::istringstream stream(input);
 
-	if (input.find(',') != std::string::npos) // code to handle conversion with comma as decimal separator
-		stream.imbue(std::locale(std::locale(), new LocaleWithComma));
+	if(input.find(',') != std::string::npos) // code to handle conversion with comma as decimal separator
+		stream.imbue(std::locale(std::locale(), new LocaleWithComma()));
 
 	float result;
 	if ( !(stream >> result) )

+ 1 - 1
lib/CHeroHandler.cpp

@@ -294,7 +294,7 @@ CHeroHandler::CHeroHandler()
 
 CHero * CHeroHandler::loadFromJson(const JsonNode & node, const std::string & identifier)
 {
-	auto  hero = new CHero;
+	auto hero = new CHero();
 	hero->identifier = identifier;
 	hero->sex = node["female"].Bool();
 	hero->special = node["special"].Bool();

+ 3 - 3
lib/CTownHandler.cpp

@@ -327,7 +327,7 @@ void CTownHandler::loadBuildingRequirements(CBuilding * building, const JsonNode
 
 void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, const JsonNode & source)
 {
-	auto ret = new CBuilding;
+	auto ret = new CBuilding();
 
 	static const std::string modes [] = {"normal", "auto", "special", "grail"};
 
@@ -406,7 +406,7 @@ void CTownHandler::loadBuildings(CTown * town, const JsonNode & source)
 
 void CTownHandler::loadStructure(CTown &town, const std::string & stringID, const JsonNode & source)
 {
-	auto ret = new CStructure;
+	auto ret = new CStructure();
 
 	ret->building = nullptr;
 	ret->buildable = nullptr;
@@ -706,7 +706,7 @@ CFaction * CTownHandler::loadFromJson(const JsonNode &source, const std::string
 
 	if (!source["town"].isNull())
 	{
-		faction->town = new CTown;
+		faction->town = new CTown();
 		faction->town->faction = faction;
 		loadTown(*faction->town, source["town"]);
 	}

+ 3 - 3
lib/VCMI_Lib.cpp

@@ -35,7 +35,7 @@ LibClasses * VLC = nullptr;
 DLL_LINKAGE void preinitDLL(CConsoleHandler *Console)
 {
 	console = Console;
-	VLC = new LibClasses;
+	VLC = new LibClasses();
 	try
 	{
 		VLC->loadFilesystem();
@@ -169,8 +169,8 @@ LibClasses::LibClasses()
 
 void LibClasses::callWhenDeserializing()
 {
-	// FIXME: check if any of these are needed
-	//generaltexth = new CGeneralTextHandler;
+	//FIXME: check if any of these are needed
+	//generaltexth = new CGeneralTextHandler();
 	//generaltexth->load();
 	//arth->load(true);
 	//modh->recreateHandlers();

+ 1 - 1
lib/filesystem/CCompressedStream.cpp

@@ -93,7 +93,7 @@ CCompressedStream::CCompressedStream(std::unique_ptr<CInputStream> stream, bool
 	assert(gzipStream);
 
 	// Allocate inflate state
-	inflateState = new z_stream;
+	inflateState = new z_stream();
 	inflateState->zalloc = Z_NULL;
 	inflateState->zfree = Z_NULL;
 	inflateState->opaque = Z_NULL;

+ 1 - 1
lib/filesystem/Filesystem.cpp

@@ -126,7 +126,7 @@ ISimpleResourceLoader * CResourceHandler::createInitial()
 {
 	//temporary filesystem that will be used to initialize main one.
 	//used to solve several case-sensivity issues like Mp3 vs MP3
-	auto initialLoader = new CFilesystemList;
+	auto initialLoader = new CFilesystemList();
 
 	//recurse only into specific directories
 	auto recurseInDir = [&](std::string URI, int depth)

+ 1 - 1
lib/mapObjects/CObjectClassesHandler.cpp

@@ -26,7 +26,7 @@
 CObjectClassesHandler::CObjectClassesHandler()
 {
 #define SET_HANDLER_CLASS(STRING, CLASSNAME) handlerConstructors[STRING] = std::make_shared<CLASSNAME>;
-#define SET_HANDLER(STRING, TYPENAME) handlerConstructors[STRING] = std::make_shared<CDefaultObjectTypeHandler<TYPENAME> >
+#define SET_HANDLER(STRING, TYPENAME) handlerConstructors[STRING] = std::make_shared<CDefaultObjectTypeHandler<TYPENAME>>
 
 	// list of all known handlers, hardcoded for now since the only way to add new objects is via C++ code
 	//Note: should be in sync with registerTypesMapObjectTypes function

+ 2 - 2
lib/serializer/Connection.cpp

@@ -50,8 +50,8 @@ void CConnection::init()
 	oser & std::string("Aiya!\n") & name & myEndianess; //identify ourselves
 	iser & pom & pom & contactEndianess;
 	logNetwork->infoStream() << "Established connection with "<<pom;
-	wmx = new boost::mutex;
-	rmx = new boost::mutex;
+	wmx = new boost::mutex();
+	rmx = new boost::mutex();
 
 	handler = nullptr;
 	receivedStop = sendStop = false;

+ 1 - 1
scripting/erm/ERMInterpreter.cpp

@@ -382,7 +382,7 @@ void ERMInterpreter::scanForScripts()
 			if (ext == ".ERM" || ext == ".VERM")
 			{
 				ERMParser ep(dir->path().string());
-				FileInfo * finfo = new FileInfo;
+				FileInfo * finfo = new FileInfo();
 				finfo->filename = dir->path().string();
 
 				std::vector<LineInfo> buf = ep.parseFile();

+ 3 - 3
server/CGameHandler.cpp

@@ -86,7 +86,7 @@ public:
 	virtual ~CBaseForGHApply(){}
 	template<typename U> static CBaseForGHApply *getApplier(const U * t=nullptr)
 	{
-		return new CApplyOnGH<U>;
+		return new CApplyOnGH<U>();
 	}
 };
 
@@ -1397,7 +1397,7 @@ CGameHandler::CGameHandler(void)
 	QID = 1;
 	//gs = nullptr;
 	IObjectInterface::cb = this;
-	applier = new CApplier<CBaseForGHApply>;
+	applier = new CApplier<CBaseForGHApply>();
 	registerTypesServerPacks(*applier);
 	visitObjectAfterVictory = false;
 
@@ -6057,7 +6057,7 @@ void CGameHandler::setBattleResult(BattleResult::EResult resultType, int victori
 		          % battleResult.data->result % resultType).str());
 		return;
 	}
-	auto br = new BattleResult;
+	auto br = new BattleResult();
 	br->result = resultType;
 	br->winner = victoriusSide; //surrendering side loses
 	gs->curB->calculateCasualties(br->casualties);

+ 1 - 1
server/CVCMIServer.cpp

@@ -615,7 +615,7 @@ int main(int argc, char** argv)
 	signal(SIGSEGV, handleLinuxSignal);
     #endif
 
-	console = new CConsoleHandler;
+	console = new CConsoleHandler();
 	CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() / "VCMI_Server_log.txt", console);
 	logConfig.configureDefault();
 	logGlobal->info(NAME);

+ 1 - 1
test/CVcmiTestConfig.cpp

@@ -23,7 +23,7 @@
 
 CVcmiTestConfig::CVcmiTestConfig()
 {
-	console = new CConsoleHandler;
+	console = new CConsoleHandler();
 	CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() / "VCMI_Test_log.txt", console);
 	logConfig.configureDefault();
 	preinitDLL(console);