Changed: Code simplification

This commit is contained in:
kervala 2012-12-08 11:24:43 +01:00
parent cb6aefd69d
commit 4d6ab65a36
10 changed files with 39 additions and 29 deletions

View file

@ -53,7 +53,7 @@ static string ListenAddr;
static bool AcceptInvalidCookie = false;
static string DefaultUserPriv = "";
static string DefaultUserPriv;
static TDisconnectClientCallback DisconnectClientCallback = NULL;

View file

@ -14,7 +14,9 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "georgesform_model.h"
#include "formitem.h"
// NeL includes
#include <nel/misc/types_nl.h>
@ -35,9 +37,6 @@
#include <QLabel>
#include <QPixmap>
// project includes
#include "formitem.h"
using namespace NLGEORGES;
namespace GeorgesQt
@ -406,7 +405,7 @@ namespace GeorgesQt
//uint value_uint;
//sint value_sint;
//double value_double;
QString elmtType = "";
QString elmtType;
UFormElm *elmt = 0;
if(root->getNodeByName(&elmt, elmName.c_str(), whereN, true))
{
@ -428,13 +427,23 @@ namespace GeorgesQt
switch (type->getType())
{
case UType::UnsignedInt:
value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toUtf8();
{
uint v;
NLMISC::fromString(value, v);
value = NLMISC::toString(v);
elmtType.append("_uint");break;
}
case UType::SignedInt:
value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toUtf8();
{
sint v;
NLMISC::fromString(value, v);
value = NLMISC::toString(v);
elmtType.append("_sint");break;
}
case UType::Double:
value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble(),0,'f',1).toUtf8();
float v;
NLMISC::fromString(value, v);
value = NLMISC::toString(v);
elmtType.append("_double");break;
case UType::String:
elmtType.append("_string");break;
@ -569,7 +578,7 @@ namespace GeorgesQt
{
QList<QVariant> columnData;
std::string value;
QString elmtType = "";
QString elmtType;
UFormElm *elmt = 0;
if(root->getArrayNode(&elmt,0) && elmt)

View file

@ -770,12 +770,13 @@ NL3D::CPSLocated *CParticleWorkspaceDialog::createLocated(NL3D::CParticleSystem
{
// build new name
std::string name;
if (_PSElementIdentifiers.count(std::string("located")))
name = (QString("located %1").arg(++_PSElementIdentifiers[std::string("located")])).toUtf8();
if (_PSElementIdentifiers.count("located"))
{
name = NLMISC::toString("located %u", ++_PSElementIdentifiers["located"]);
}
else
{
name = std::string("located 0");
name = "located 0";
_PSElementIdentifiers["located"] = 0;
}
NL3D::CPSLocated *loc = new NL3D::CPSLocated;

View file

@ -989,7 +989,7 @@ bool CScenarioValidator::setScenarioToSave(const std::string& filename, CObject*
return true;
}
std::string CScenarioValidator::AutoSaveSignature = "";
std::string CScenarioValidator::AutoSaveSignature;
bool CScenarioValidator::applySave(const std::string& signature)
{
@ -1252,7 +1252,7 @@ bool CUserComponentValidator::setUserComponentToSave(const std::string& filename
return true;
}
std::string CUserComponentValidator::AutoSaveSignature = "";
std::string CUserComponentValidator::AutoSaveSignature;
bool CUserComponentValidator::applySave(const std::string& signature)
{

View file

@ -2017,7 +2017,7 @@ bool CServerAnimationModule::doMakeAnimationSession(CAnimationSession* animSessi
//first <=> actId
CPrimitives *primDoc = &primDocs[first];
std::string streamFileName = "";
std::string streamFileName;
if (first==0)
{
streamFileName= toString("r2.%04d.base.primitive", aiInstance);

View file

@ -2023,7 +2023,7 @@ void CExport::writeFloraIG (const string &LandFile, bool bTestForWriting)
// Make the .IG
string ZoneName = "";
string ZoneName;
ZoneName += NLMISC::toString(-j) + "_";
ZoneName += 'a' + (i/26);
ZoneName += 'a' + (i%26);

View file

@ -380,7 +380,7 @@ namespace NLQT
//uint value_uint;
//sint value_sint;
//double value_double;
QString elmtType = "";
QString elmtType;
UFormElm *elmt = 0;
if(root->getNodeByName(&elmt, elmName.c_str(), whereN, true))
{
@ -542,7 +542,7 @@ namespace NLQT
{
QList<QVariant> columnData;
std::string value;
QString elmtType = "";
QString elmtType;
UFormElm *elmt = 0;
if(root->getArrayNode(&elmt,0) && elmt)

View file

@ -1809,7 +1809,7 @@ string CContentObjective::genCode(CMissionData &md)
// ---------------------------------------------------------------------------
/*std::string CContentObjective::genNbGuildMembersNeededOption(CMissionData &md)
{
string ret = "";
string ret;
// If we are in a guild mission we add the 'nb_guild_members_needed' option to the script
if (md.isGuildMission())
{

View file

@ -1455,7 +1455,7 @@ void GenerateDoc()
AltDocs[c].write( "<td><b><a href=\"rm_" + string(DataColStr[cc]) + ".html\">" + string(DataColStr[cc]) + "</a></b></td>" );
AltDocs[c].write( "</tr>" );
string previousKey = "[NO PREVIOUS]"; // not a blank string, because it may be a valid value
string previousName = "";
string previousName;
for ( CRMData::CLookup::const_iterator isd=SortableData.lookup( c ).begin(); isd!=SortableData.lookup( c ).end(); ++isd )
{
const TRMItem& item = SortableData.getRow( (*isd).second );

View file

@ -870,7 +870,7 @@ public:
std::string getIndexName(uint32 value) const
{
std::string result = "";
std::string result;
uint i;
for (i=0; i<Values.size(); ++i)
@ -1055,7 +1055,7 @@ public:
std::string getCallString()
{
uint i;
std::string res = "";
std::string res;
for (i=0; i<Context.size(); ++i)
res += Context[i]->Name;
return res;
@ -1078,7 +1078,7 @@ public:
std::string getDebugCallStringFmt()
{
uint i, idx=0;
std::string res = "";
std::string res;
for (i=0; i<Context.size(); ++i)
{
@ -1105,7 +1105,7 @@ public:
std::string getDebugCallStringVal()
{
uint i, idx=0;
std::string res = "";
std::string res;
for (i=0; i<Context.size(); ++i)
{
@ -1131,7 +1131,7 @@ public:
*/
std::string getCallArgList()
{
std::string res = "";
std::string res;
uint i, idx=0;
for (i=0; i<Context.size(); ++i)
@ -1156,7 +1156,7 @@ public:
*/
std::string getCallPath()
{
std::string res = "";
std::string res;
uint i, idx=0;
for (i=0; i<Context.size(); ++i)
@ -1182,7 +1182,7 @@ public:
*/
std::string getUserCodeContext()
{
std::string res = "";
std::string res;
uint i;
if (Context.empty())
@ -1245,7 +1245,7 @@ public:
std::string getColumn()
{
std::string res = "";
std::string res;
uint i, idx=0;
for (i=0; i<Context.size(); ++i)