mirror of
https://github.com/glest/glest-source.git
synced 2025-09-26 23:49:03 +02:00
- fixed some bugs discovered by coverity scan
This commit is contained in:
@@ -622,7 +622,7 @@ const Resource *AiInterface::getResource(const ResourceType *rt){
|
||||
}
|
||||
|
||||
Unit *AiInterface::getMyUnitPtr(int unitIndex) {
|
||||
if(unitIndex >= world->getFaction(factionIndex)->getUnitCount()) {
|
||||
if(unitIndex < 0 || unitIndex >= world->getFaction(factionIndex)->getUnitCount()) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] unitIndex >= world->getFaction(factionIndex)->getUnitCount(), unitIndex = %d, world->getFaction(factionIndex)->getUnitCount() = %d",__FILE__,__FUNCTION__,__LINE__,unitIndex,world->getFaction(factionIndex)->getUnitCount());
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
|
@@ -1305,6 +1305,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
|
||||
//besti=i%(producers.size());
|
||||
}
|
||||
}
|
||||
if(bestIndex >= 0) {
|
||||
if( aiInterface->getMyUnit(bestIndex)->getCommandSize() > 2) {
|
||||
// maybe we need another producer of this kind if possible!
|
||||
if(aiInterface->reqsOk(aiInterface->getMyUnit(bestIndex)->getType())) {
|
||||
@@ -1421,9 +1422,8 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
|
||||
aiInterface->giveCommand(bestIndex, defCt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(currentCommandCount==0) {
|
||||
else {
|
||||
if(currentCommandCount == 0) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
defCt = NULL;
|
||||
if(producersDefaultCommandType.find(bestIndex) != producersDefaultCommandType.end()) {
|
||||
@@ -1466,6 +1466,7 @@ void AiRuleProduce::produceSpecific(const ProduceTask *pt){
|
||||
aiInterface->giveCommand(bestIndex, defCt);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int pIndex = ai->getRandom()->randRange(0, (int)producers.size()-1);
|
||||
int producerIndex= producers[pIndex];
|
||||
|
@@ -2012,6 +2012,9 @@ void NetworkMessageCommandList::fromEndianDetail() {
|
||||
// class NetworkMessageText
|
||||
// =====================================================
|
||||
|
||||
NetworkMessageText::NetworkMessageText() {
|
||||
messageType = nmtText;
|
||||
}
|
||||
NetworkMessageText::NetworkMessageText(const string &text, int teamIndex, int playerIndex,
|
||||
const string targetLanguage) {
|
||||
if((int)text.length() >= maxTextStringSize) {
|
||||
@@ -2759,6 +2762,10 @@ void NetworkMessageSynchNetworkGameDataStatus::fromEndianDetail() {
|
||||
// class NetworkMessageSynchNetworkGameDataFileCRCCheck
|
||||
// =====================================================
|
||||
|
||||
NetworkMessageSynchNetworkGameDataFileCRCCheck::NetworkMessageSynchNetworkGameDataFileCRCCheck() {
|
||||
messageType= nmtSynchNetworkGameDataFileCRCCheck;
|
||||
}
|
||||
|
||||
NetworkMessageSynchNetworkGameDataFileCRCCheck::NetworkMessageSynchNetworkGameDataFileCRCCheck(
|
||||
uint32 totalFileCount, uint32 fileIndex, uint32 fileCRC, const string fileName)
|
||||
{
|
||||
@@ -2872,7 +2879,9 @@ void NetworkMessageSynchNetworkGameDataFileCRCCheck::fromEndian() {
|
||||
// =====================================================
|
||||
// class NetworkMessageSynchNetworkGameDataFileGet
|
||||
// =====================================================
|
||||
|
||||
NetworkMessageSynchNetworkGameDataFileGet::NetworkMessageSynchNetworkGameDataFileGet() {
|
||||
messageType= nmtSynchNetworkGameDataFileGet;
|
||||
}
|
||||
NetworkMessageSynchNetworkGameDataFileGet::NetworkMessageSynchNetworkGameDataFileGet(const string fileName) {
|
||||
messageType= nmtSynchNetworkGameDataFileGet;
|
||||
data.fileName = fileName;
|
||||
@@ -3307,6 +3316,9 @@ void NetworkMessageLoadingStatus::fromEndian() {
|
||||
// =====================================================
|
||||
// class NetworkMessageMarkCell
|
||||
// =====================================================
|
||||
NetworkMessageMarkCell::NetworkMessageMarkCell() {
|
||||
messageType = nmtMarkCell;
|
||||
}
|
||||
|
||||
NetworkMessageMarkCell::NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text, int playerIndex) {
|
||||
if((int)text.length() >= maxTextStringSize) {
|
||||
|
@@ -520,7 +520,7 @@ protected:
|
||||
virtual unsigned char * packMessage();
|
||||
|
||||
public:
|
||||
NetworkMessageText(){}
|
||||
NetworkMessageText();
|
||||
NetworkMessageText(const string &text, int teamIndex, int playerIndex,
|
||||
const string targetLanguage);
|
||||
|
||||
@@ -793,7 +793,7 @@ protected:
|
||||
virtual unsigned char * packMessage();
|
||||
|
||||
public:
|
||||
NetworkMessageSynchNetworkGameDataFileCRCCheck() {};
|
||||
NetworkMessageSynchNetworkGameDataFileCRCCheck();
|
||||
NetworkMessageSynchNetworkGameDataFileCRCCheck(uint32 totalFileCount, uint32 fileIndex, uint32 fileCRC, const string fileName);
|
||||
|
||||
virtual size_t getDataSize() const { return sizeof(Data); }
|
||||
@@ -845,7 +845,7 @@ protected:
|
||||
virtual unsigned char * packMessage();
|
||||
|
||||
public:
|
||||
NetworkMessageSynchNetworkGameDataFileGet() {};
|
||||
NetworkMessageSynchNetworkGameDataFileGet();
|
||||
NetworkMessageSynchNetworkGameDataFileGet(const string fileName);
|
||||
|
||||
virtual size_t getDataSize() const { return sizeof(Data); }
|
||||
@@ -1089,7 +1089,7 @@ protected:
|
||||
virtual unsigned char * packMessage();
|
||||
|
||||
public:
|
||||
NetworkMessageMarkCell(){}
|
||||
NetworkMessageMarkCell();
|
||||
NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text, int playerIndex);
|
||||
|
||||
virtual size_t getDataSize() const { return sizeof(Data); }
|
||||
|
@@ -85,6 +85,7 @@ private:
|
||||
string fileName;
|
||||
|
||||
public:
|
||||
OggSoundFileLoader();
|
||||
virtual void open(const string &path, SoundInfo *soundInfo);
|
||||
virtual uint32 read(int8 *samples, uint32 size);
|
||||
virtual void close();
|
||||
|
@@ -254,6 +254,9 @@ int zipfile_tool(int argc, const char *argv[]) {
|
||||
uint n = BUF_SIZE - stream.avail_out;
|
||||
if (fwrite(s_outbuf, 1, n, pOutfile) != n) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Failed writing to output file!\n");
|
||||
|
||||
if(pInfile) fclose(pInfile);
|
||||
if(pOutfile) fclose(pOutfile);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
stream.next_out = s_outbuf;
|
||||
|
@@ -107,7 +107,7 @@ public:
|
||||
base_thread->signalQuit();
|
||||
sleep(10);
|
||||
|
||||
if(Thread::getEnableVerboseMode()) printf("!!!! cleanupPendingThread Line: %d thread = %p [%s]\n",__LINE__,thread,(base_thread != NULL ? base_thread->getUniqueID().c_str() : "n/a"));
|
||||
if(Thread::getEnableVerboseMode()) printf("!!!! cleanupPendingThread Line: %d thread = %p [%s]\n",__LINE__,thread,base_thread->getUniqueID().c_str());
|
||||
|
||||
if(base_thread->getRunningStatus() == true || base_thread->getExecutingTask() == true) {
|
||||
|
||||
|
@@ -201,6 +201,11 @@ void WavSoundFileLoader::restart(){
|
||||
// Ogg Sound File Loader
|
||||
// =======================================
|
||||
|
||||
OggSoundFileLoader::OggSoundFileLoader() {
|
||||
vf = NULL;
|
||||
f = NULL;
|
||||
}
|
||||
|
||||
void OggSoundFileLoader::open(const string &path, SoundInfo *soundInfo){
|
||||
fileName = path;
|
||||
|
||||
|
Reference in New Issue
Block a user