Changed: #825 Remove all warning when compiling Ryzom

This commit is contained in:
kervala 2010-08-11 12:33:23 +02:00
parent fb9cbfe4c0
commit 59170cb99c
12 changed files with 98 additions and 30 deletions

View file

@ -209,7 +209,6 @@ int main()
double rGlobalTime = 0; double rGlobalTime = 0;
double rOldGlobalTime = 0; double rOldGlobalTime = 0;
double rDeltaTime = 0; double rDeltaTime = 0;
double rMoveTime = 0;
vector<SDispCS> DispCS; vector<SDispCS> DispCS;
@ -430,7 +429,7 @@ int main()
{ {
nSelected--; nSelected--;
if(nSelected == -1) if(nSelected == -1)
nSelected = DispCS.size()-1; nSelected = (sint32)DispCS.size()-1;
} }
if (CNELU::AsyncListener.isKeyPushed (KeyS)) if (CNELU::AsyncListener.isKeyPushed (KeyS))
{ {

View file

@ -92,7 +92,7 @@ void CGraphicsViewport::init(CGraphicsConfig *graphicsConfig)
nlassert(m_Driver); nlassert(m_Driver);
// initialize the window with config file values // initialize the window with config file values
m_Driver->setDisplay((void *)winId(), NL3D::UDriver::CMode(width(), height(), 32)); m_Driver->setDisplay(winId(), NL3D::UDriver::CMode(width(), height(), 32));
// register config callbacks // register config callbacks
connect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)), connect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)),

View file

@ -58,7 +58,7 @@ void var12Callback (CConfigFile::CVar &var)
// the configfile // the configfile
CConfigFile cf; CConfigFile cf;
int main (int argc, char **argv) int main (int /* argc */, char ** /* argv */)
{ {
// look at the debug example // look at the debug example
@ -87,14 +87,17 @@ int main (int argc, char **argv)
// get the value of var1 as int // get the value of var1 as int
int var1 = cf.getVar ("var1").asInt(); int var1 = cf.getVar ("var1").asInt();
nlinfo("var1 (int) = %d", var1);
// get the value of var1 as double, in this case, a conversion from int // get the value of var1 as double, in this case, a conversion from int
// to double will be done // to double will be done
double var2 = cf.getVar ("var1").asDouble(); double var2 = cf.getVar ("var1").asDouble();
nlinfo("var1 (double) = %lf", var2);
// get the value of var2 as int, in this case, a conversion from string // get the value of var2 as int, in this case, a conversion from string
// to int will be done // to int will be done
int var3 = cf.getVar ("var2").asInt(); int var3 = cf.getVar ("var2").asInt();
nlinfo("var2 = %d", var3);
// if the variable is an array of values, you can access them putting the // if the variable is an array of values, you can access them putting the
// index of the variable you want. Example, get and print all value of var12: // index of the variable you want. Example, get and print all value of var12:
@ -111,6 +114,7 @@ int main (int argc, char **argv)
{ {
// try to access an unknown variable // try to access an unknown variable
int val = cf.getVar ("unknown_variable").asInt(); int val = cf.getVar ("unknown_variable").asInt();
nlinfo("unknown_variable = %d", val);
} }
catch (EConfigFile &e) catch (EConfigFile &e)
{ {

View file

@ -22,7 +22,7 @@
using namespace NLMISC; using namespace NLMISC;
int main (int argc, char **argv) int main (int /* argc */, char ** /* argv */)
{ {
// all debug functions have different behaviors in debug and in release mode. // all debug functions have different behaviors in debug and in release mode.
// in general, in debug mode, all debug functions are active, they display // in general, in debug mode, all debug functions are active, they display

View file

@ -40,7 +40,7 @@ CFileDisplayer fd("main.log",true);
// Windows, it does nothing on other systems. // Windows, it does nothing on other systems.
CMsgBoxDisplayer mbd; CMsgBoxDisplayer mbd;
int main (int argc, char **argv) int main (int /* argc */, char ** /* argv */)
{ {
// create a logger; it's an information logger. // create a logger; it's an information logger.
CLog logger (CLog::LOG_INFO); CLog logger (CLog::LOG_INFO);

View file

@ -71,7 +71,8 @@ int getch()
peek_character = -1; peek_character = -1;
return ch; return ch;
} }
read(STDIN_FILENO,&ch,1); if (read(STDIN_FILENO,&ch,1) != 1)
nlwarning("Can't read keyboard");
return ch; return ch;
} }

View file

@ -117,8 +117,11 @@ int main (int argc, char **argv)
sint32 sid = ConfigFile.getVar("ShardId").asInt(); sint32 sid = ConfigFile.getVar("ShardId").asInt();
if(sid == 0) if(sid == 0)
{ {
printf("Enter the SharId you want to connect to: "); printf("Enter the ShardId you want to connect to: ");
scanf("%d", sid); if (scanf("%d", &sid) != 1)
{
nlwarning("Can't parse ShardId");
}
} }
/* Try to connect to the shard number 0 in the list. /* Try to connect to the shard number 0 in the list.

View file

@ -196,7 +196,7 @@ void cbInit (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
msgout.serial (session); msgout.serial (session);
CallbackServer->send (msgout, from); CallbackServer->send (msgout, from);
Clients.push_back(CClient(from, session, connectionName)); Clients.push_back(CClient(from, (uint32)session, connectionName));
nlinfo ("Added client TCP %s, session %x", from->asString().c_str(), session); nlinfo ("Added client TCP %s, session %x", from->asString().c_str(), session);
} }
@ -517,7 +517,7 @@ void handleReceivedPong (CClient *client, sint64 pongTime)
memcpy (msgin.bufferToFill (currentsize), CurrentInMsg->userDataR(), currentsize); memcpy (msgin.bufferToFill (currentsize), CurrentInMsg->userDataR(), currentsize);
// Read the header // Read the header
uint8 mode; uint8 mode = 0;
msgin.serial (mode); msgin.serial (mode);
if (mode == 0) if (mode == 0)

View file

@ -380,13 +380,13 @@ int main( int argc, char **argv )
CMemStream msgin( true ); CMemStream msgin( true );
memcpy (msgin.bufferToFill (psize), packet, psize); memcpy (msgin.bufferToFill (psize), packet, psize);
sint64 t; sint64 t = 0;
msgin.serial (t); msgin.serial (t);
uint32 p; uint32 p = 0;
msgin.serial (p); msgin.serial (p);
uint32 b; uint32 b = 0;
msgin.serial (b); msgin.serial (b);
// I received a ping, send a pong // I received a ping, send a pong

View file

@ -376,7 +376,7 @@ int main ()
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
::MessageBox (NULL, e.what(), "Test collision move", MB_OK|MB_ICONEXCLAMATION); ::MessageBox (NULL, e.what(), "Test collision move", MB_OK|MB_ICONEXCLAMATION);
#else // NL_OS_WINDOWS #else // NL_OS_WINDOWS
printf (e.what()); printf ("%s\n", e.what());
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
} }

View file

@ -79,16 +79,44 @@ struct BNPHeader
if (f == NULL) return false; if (f == NULL) return false;
uint32 nNbFile = (uint32)Files.size(); uint32 nNbFile = (uint32)Files.size();
fwrite (&nNbFile, sizeof(uint32), 1, f); if (fwrite (&nNbFile, sizeof(uint32), 1, f) != 1)
{
fclose(f);
return false;
}
for (uint32 i = 0; i < nNbFile; ++i) for (uint32 i = 0; i < nNbFile; ++i)
{ {
uint8 nStringSize = (uint8)Files[i].Name.size(); uint8 nStringSize = (uint8)Files[i].Name.size();
fwrite (&nStringSize, 1, 1, f); if (fwrite (&nStringSize, 1, 1, f) != 1)
fwrite (Files[i].Name.c_str(), 1, nStringSize, f); {
fwrite (&Files[i].Size, sizeof(uint32), 1, f); fclose(f);
fwrite (&Files[i].Pos, sizeof(uint32), 1, f); return false;
}
if (fwrite (Files[i].Name.c_str(), 1, nStringSize, f) != nStringSize)
{
fclose(f);
return false;
}
if (fwrite (&Files[i].Size, sizeof(uint32), 1, f) != 1)
{
fclose(f);
return false;
}
if (fwrite (&Files[i].Pos, sizeof(uint32), 1, f) != 1)
{
fclose(f);
return false;
}
}
if (fwrite (&OffsetFromBeginning, sizeof(uint32), 1, f) != 1)
{
fclose(f);
return false;
} }
fwrite (&OffsetFromBeginning, sizeof(uint32), 1, f);
fclose (f); fclose (f);
return true; return true;
@ -103,29 +131,54 @@ struct BNPHeader
nlfseek64 (f, 0, SEEK_END); nlfseek64 (f, 0, SEEK_END);
uint32 nFileSize=CFile::getFileSize (filename); uint32 nFileSize=CFile::getFileSize (filename);
nlfseek64 (f, nFileSize-sizeof(uint32), SEEK_SET); nlfseek64 (f, nFileSize-sizeof(uint32), SEEK_SET);
uint32 nOffsetFromBegining; uint32 nOffsetFromBegining;
fread (&nOffsetFromBegining, sizeof(uint32), 1, f); if (fread (&nOffsetFromBegining, sizeof(uint32), 1, f) != 1)
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0) {
fclose (f);
return false; return false;
}
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0)
{
fclose (f);
return false;
}
uint32 nNbFile; uint32 nNbFile;
if (fread (&nNbFile, sizeof(uint32), 1, f) != 1) if (fread (&nNbFile, sizeof(uint32), 1, f) != 1)
{
fclose (f);
return false; return false;
}
for (uint32 i = 0; i < nNbFile; ++i) for (uint32 i = 0; i < nNbFile; ++i)
{ {
uint8 nStringSize; uint8 nStringSize;
char sName[256]; char sName[256];
if (fread (&nStringSize, 1, 1, f) != 1) if (fread (&nStringSize, 1, 1, f) != 1)
{
fclose (f);
return false; return false;
}
if (fread (sName, 1, nStringSize, f) != nStringSize) if (fread (sName, 1, nStringSize, f) != nStringSize)
{
fclose (f);
return false; return false;
}
sName[nStringSize] = 0; sName[nStringSize] = 0;
BNPFile tmpBNPFile; BNPFile tmpBNPFile;
tmpBNPFile.Name = sName; tmpBNPFile.Name = sName;
if (fread (&tmpBNPFile.Size, sizeof(uint32), 1, f) != 1) if (fread (&tmpBNPFile.Size, sizeof(uint32), 1, f) != 1)
{
fclose (f);
return false; return false;
}
if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1) if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1)
{
fclose (f);
return false; return false;
}
Files.push_back (tmpBNPFile); Files.push_back (tmpBNPFile);
} }
@ -146,9 +199,11 @@ void append(const string &filename1, const string &filename2, uint32 sizeToRead)
if (f2 == NULL) { fclose(f1); return; } if (f2 == NULL) { fclose(f1); return; }
uint8 *ptr = new uint8[sizeToRead]; uint8 *ptr = new uint8[sizeToRead];
fread (ptr, sizeToRead, 1, f2); if (fread (ptr, sizeToRead, 1, f2) != 1)
fwrite (ptr, sizeToRead, 1, f1); nlwarning("%s read error", filename2.c_str());
delete ptr; if (fwrite (ptr, sizeToRead, 1, f1) != 1)
nlwarning("%s write error", filename1.c_str());
delete [] ptr;
fclose(f2); fclose(f2);
fclose(f1); fclose(f1);
@ -216,10 +271,12 @@ void unpack (const string &dirName)
{ {
nlfseek64 (bnp, rBNPFile.Pos, SEEK_SET); nlfseek64 (bnp, rBNPFile.Pos, SEEK_SET);
uint8 *ptr = new uint8[rBNPFile.Size]; uint8 *ptr = new uint8[rBNPFile.Size];
fread (ptr, rBNPFile.Size, 1, bnp); if (fread (ptr, rBNPFile.Size, 1, bnp) != 1)
fwrite (ptr, rBNPFile.Size, 1, out); nlwarning("%s read error", filename.c_str());
if (fwrite (ptr, rBNPFile.Size, 1, out) != 1)
nlwarning("%s write error", filename.c_str());
fclose (out); fclose (out);
delete ptr; delete [] ptr;
} }
} }
fclose (bnp); fclose (bnp);

View file

@ -297,7 +297,11 @@ int main(int argc, char *argv[])
} }
fclose(fp); fclose(fp);
// set the file 'hidden'n use the plain old system command... // set the file 'hidden'n use the plain old system command...
system(toString("attrib +h %s", indexFileName.c_str()).c_str()); sint res = system(toString("attrib +h %s", indexFileName.c_str()).c_str());
if (res)
{
nlwarning("attrib failed with return code %d", res);
}
} }
else else
{ {