mirror of
https://github.com/unknownworlds/NS.git
synced 2024-11-13 00:24:33 +00:00
Particle system load error on linux servers
git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@226 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
parent
7ef6e421e4
commit
f3b0864612
3 changed files with 64 additions and 15 deletions
|
@ -2065,6 +2065,9 @@ void AvHGamerules::PreWorldPrecacheInitParticles()
|
|||
// Load up the particle systems from modname.ps then levelname.ps
|
||||
TRDescriptionList theDescriptionList;
|
||||
|
||||
|
||||
bool success=false;
|
||||
#ifndef LINUX
|
||||
char *pbuffer = NULL;
|
||||
int len;
|
||||
// Read them in from proper file
|
||||
|
@ -2072,12 +2075,20 @@ void AvHGamerules::PreWorldPrecacheInitParticles()
|
|||
ASSERT(pbuffer);
|
||||
|
||||
strstream trstream(pbuffer, len);
|
||||
if(TRFactory::ReadDescriptions(trstream, theDescriptionList))
|
||||
|
||||
success=TRFactory::ReadDescriptionsFromStream(trstream, theDescriptionList);
|
||||
#else
|
||||
success=TRFactory::ReadDescriptionsFromFile(string(getModDirectory()) + "/" + kBasePSName, theDescriptionList);
|
||||
#endif
|
||||
|
||||
if(success)
|
||||
{
|
||||
gParticleTemplateList.CreateTemplates(theDescriptionList);
|
||||
}
|
||||
theDescriptionList.clear();
|
||||
#ifndef LINUX
|
||||
FREE_FILE(pbuffer);
|
||||
#endif
|
||||
|
||||
// TODO: the level name isn't populated yet for some reason
|
||||
const char* theCStrLevelName = STRING(gpGlobals->mapname);
|
||||
|
@ -2085,17 +2096,26 @@ void AvHGamerules::PreWorldPrecacheInitParticles()
|
|||
{
|
||||
string theLevelName = theCStrLevelName;
|
||||
string theLevelParticleSystemFile = theLevelName + string(".ps");
|
||||
// Read them in from proper file
|
||||
pbuffer = (char *)LOAD_FILE_FOR_ME( (char *)theLevelParticleSystemFile.c_str(), &len ); // Use malloc
|
||||
if ( pbuffer ) {
|
||||
#ifndef LINUX
|
||||
char *pbuffer = NULL;
|
||||
int len;
|
||||
// Read them in from proper file
|
||||
pbuffer = (char *)LOAD_FILE_FOR_ME( kBasePSName, &len ); // Use malloc
|
||||
ASSERT(pbuffer);
|
||||
|
||||
strstream trstream(pbuffer, len);
|
||||
if(TRFactory::ReadDescriptions(trstream, theDescriptionList))
|
||||
{
|
||||
gParticleTemplateList.CreateTemplates(theDescriptionList);
|
||||
}
|
||||
FREE_FILE(pbuffer);
|
||||
strstream trstream(pbuffer, len);
|
||||
|
||||
success=TRFactory::ReadDescriptionsFromStream(trstream, theDescriptionList);
|
||||
#else
|
||||
success=TRFactory::ReadDescriptionsFromFile(theLevelParticleSystemFile, theDescriptionList);
|
||||
#endif
|
||||
if(success)
|
||||
{
|
||||
gParticleTemplateList.CreateTemplates(theDescriptionList);
|
||||
}
|
||||
#ifndef LINUX
|
||||
FREE_FILE(pbuffer);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
const int maxLineLength = 256;
|
||||
|
||||
bool TRFactory::ReadDescriptions(strstream &trstream, TRDescriptionList& outDescriptionList)
|
||||
bool TRFactory::ReadDescriptionsFromStream(strstream &trstream, TRDescriptionList& outDescriptionList)
|
||||
{
|
||||
bool theSuccess = false;
|
||||
bool theDescriptionRead = false;
|
||||
|
@ -52,6 +52,34 @@ bool TRFactory::ReadDescriptions(strstream &trstream, TRDescriptionList& outDesc
|
|||
return theSuccess;
|
||||
}
|
||||
|
||||
bool TRFactory::ReadDescriptionsFromFile(const string& inRelativePathFilename, TRDescriptionList& outDescriptionList)
|
||||
{
|
||||
bool theSuccess = false;
|
||||
bool theDescriptionRead = false;
|
||||
fstream trstream;
|
||||
trstream.open(inRelativePathFilename.c_str());
|
||||
if ( trstream.is_open() ) {
|
||||
do {
|
||||
// Try to read the next description in
|
||||
TRDescription theNextDescription;
|
||||
theDescriptionRead = ReadDescription(trstream, theNextDescription);
|
||||
|
||||
// add it to the description list
|
||||
if(theDescriptionRead)
|
||||
{
|
||||
// Function is successful if at least one description was found
|
||||
outDescriptionList.push_back(theNextDescription);
|
||||
theSuccess = true;
|
||||
}
|
||||
else {
|
||||
int a=0;
|
||||
}
|
||||
} while(theDescriptionRead);
|
||||
trstream.close();
|
||||
}
|
||||
return theSuccess;
|
||||
}
|
||||
|
||||
bool TRFactory::WriteDescriptions(const string& inRelativePathFilename, const TRDescriptionList& inDescriptionList, const string& inHeader)
|
||||
{
|
||||
bool theSuccess = false;
|
||||
|
@ -88,7 +116,7 @@ bool TRFactory::WriteDescriptions(const string& inRelativePathFilename, const TR
|
|||
}
|
||||
|
||||
// TODO: Add case-insensitivity
|
||||
bool TRFactory::ReadDescription(strstream& infile, TRDescription& outDescription)
|
||||
bool TRFactory::ReadDescription(istream& infile, TRDescription& outDescription)
|
||||
{
|
||||
bool theSuccess = false;
|
||||
string currentLine;
|
||||
|
|
|
@ -28,11 +28,12 @@ class TRFactory
|
|||
{
|
||||
public:
|
||||
// Read all the descriptions from the file
|
||||
static bool ReadDescriptions(strstream& trstream, TRDescriptionList& outDescriptionList);
|
||||
static bool ReadDescriptionsFromStream(strstream& trstream, TRDescriptionList& outDescriptionList);
|
||||
static bool ReadDescriptionsFromFile(const string& inRelativePathFilename, TRDescriptionList& outDescriptionList);
|
||||
static bool WriteDescriptions(const string& inRelativePathFilename, const TRDescriptionList& inDescriptionList, const string& inHeader);
|
||||
|
||||
private:
|
||||
static bool ReadDescription(strstream& infile, TRDescription& outDescription);
|
||||
static bool ReadDescription(istream& infile, TRDescription& outDescription);
|
||||
static bool WriteDescription(fstream& outfile, const TRDescription& inDescription);
|
||||
|
||||
static bool charIsWhiteSpace(char inChar);
|
||||
|
@ -45,4 +46,4 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue