Merge pull request #34 from jeefo/develop
load memory files without modname
This commit is contained in:
commit
0433f50f04
4 changed files with 36 additions and 18 deletions
|
|
@ -1425,8 +1425,8 @@ public:
|
||||||
void SetGoalVisited (int index);
|
void SetGoalVisited (int index);
|
||||||
void ClearVisitedGoals (void);
|
void ClearVisitedGoals (void);
|
||||||
|
|
||||||
const char *GetDataDir (void);
|
const char *GetDataDir (bool isMemoryFile = false);
|
||||||
String CheckSubfolderFile (void);
|
const char *GetFileName (bool isMemoryFile = false);
|
||||||
|
|
||||||
void SetBombPosition (bool shouldReset = false);
|
void SetBombPosition (bool shouldReset = false);
|
||||||
inline const Vector &GetBombPosition (void) { return m_foundBombOrigin; }
|
inline const Vector &GetBombPosition (void) { return m_foundBombOrigin; }
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ void Engine::ClientPrintf (edict_t *ent, const char *fmt, ...)
|
||||||
vsnprintf (string, SIZEOF_CHAR (string), TraslateMessage (fmt), ap);
|
vsnprintf (string, SIZEOF_CHAR (string), TraslateMessage (fmt), ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
if (IsNullEntity (ent) || ent == g_hostEntity)
|
if (IsDedicatedServer () || IsNullEntity (ent) || ent == g_hostEntity)
|
||||||
{
|
{
|
||||||
Printf (string);
|
Printf (string);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -462,24 +462,35 @@ bool OpenConfig (const char *fileName, const char *errorIfNotExists, MemoryFile
|
||||||
if (outFile->IsValid ())
|
if (outFile->IsValid ())
|
||||||
outFile->Close ();
|
outFile->Close ();
|
||||||
|
|
||||||
|
// save config dir
|
||||||
|
const char *configDir = "addons/yapb/conf";
|
||||||
|
|
||||||
if (languageDependant)
|
if (languageDependant)
|
||||||
{
|
{
|
||||||
const char *mod = engine.GetModName ();
|
|
||||||
extern ConVar yb_language;
|
extern ConVar yb_language;
|
||||||
|
|
||||||
if (strcmp (fileName, "lang.cfg") == 0 && strcmp (yb_language.GetString (), "en") == 0)
|
if (strcmp (fileName, "lang.cfg") == 0 && strcmp (yb_language.GetString (), "en") == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const char *languageDependantConfigFile = FormatBuffer ("%s/addons/yapb/conf/lang/%s_%s", mod, yb_language.GetString (), fileName);
|
const char *langConfig = FormatBuffer ("%s/lang/%s_%s", configDir, yb_language.GetString (), fileName);
|
||||||
|
|
||||||
|
// check file existence
|
||||||
|
int size = 0;
|
||||||
|
unsigned char *buffer = NULL;
|
||||||
|
|
||||||
// check is file is exists for this language
|
// check is file is exists for this language
|
||||||
if (File::Accessible (languageDependantConfigFile))
|
if ((buffer = MemoryFile::Loader (langConfig, &size)) != NULL)
|
||||||
outFile->Open (languageDependantConfigFile);
|
{
|
||||||
|
MemoryFile::Unloader (buffer);
|
||||||
|
|
||||||
|
// unload and reopen file using MemoryFile
|
||||||
|
outFile->Open (langConfig);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
outFile->Open (FormatBuffer ("%s/addons/yapb/conf/lang/en_%s", mod, fileName));
|
outFile->Open (FormatBuffer ("%s/lang/en_%s", configDir, fileName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
outFile->Open (FormatBuffer ("%s/addons/yapb/conf/%s", engine.GetModName (), fileName));
|
outFile->Open (FormatBuffer ("%s/%s", configDir, fileName));
|
||||||
|
|
||||||
if (!outFile->IsValid ())
|
if (!outFile->IsValid ())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1064,7 +1064,7 @@ bool Waypoint::Load (void)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MemoryFile fp (CheckSubfolderFile ());
|
MemoryFile fp (GetFileName (true));
|
||||||
|
|
||||||
WaypointHeader header;
|
WaypointHeader header;
|
||||||
memset (&header, 0, sizeof (header));
|
memset (&header, 0, sizeof (header));
|
||||||
|
|
@ -1242,7 +1242,7 @@ void Waypoint::Save (void)
|
||||||
header.fileVersion = FV_WAYPOINT;
|
header.fileVersion = FV_WAYPOINT;
|
||||||
header.pointNumber = g_numWaypoints;
|
header.pointNumber = g_numWaypoints;
|
||||||
|
|
||||||
File fp (CheckSubfolderFile (), "wb");
|
File fp (GetFileName (), "wb");
|
||||||
|
|
||||||
// file was opened
|
// file was opened
|
||||||
if (fp.IsValid ())
|
if (fp.IsValid ())
|
||||||
|
|
@ -1260,19 +1260,19 @@ void Waypoint::Save (void)
|
||||||
AddLogEntry (true, LL_ERROR, "Error writing '%s.pwf' waypoint file", engine.GetMapName ());
|
AddLogEntry (true, LL_ERROR, "Error writing '%s.pwf' waypoint file", engine.GetMapName ());
|
||||||
}
|
}
|
||||||
|
|
||||||
String Waypoint::CheckSubfolderFile (void)
|
const char *Waypoint::GetFileName (bool isMemoryFile)
|
||||||
{
|
{
|
||||||
String returnFile = "";
|
String returnFile = "";
|
||||||
|
|
||||||
if (!IsNullString (yb_wptsubfolder.GetString ()))
|
if (!IsNullString (yb_wptsubfolder.GetString ()))
|
||||||
returnFile += (String (yb_wptsubfolder.GetString ()) + "/");
|
returnFile += (String (yb_wptsubfolder.GetString ()) + "/");
|
||||||
|
|
||||||
returnFile = FormatBuffer ("%s%s%s.pwf", GetDataDir (), returnFile.GetBuffer (), engine.GetMapName ());
|
returnFile = FormatBuffer ("%s%s%s.pwf", GetDataDir (isMemoryFile), returnFile.GetBuffer (), engine.GetMapName ());
|
||||||
|
|
||||||
if (File::Accessible (returnFile))
|
if (File::Accessible (returnFile))
|
||||||
return returnFile;
|
return returnFile.GetBuffer ();
|
||||||
|
|
||||||
return FormatBuffer ("%s%s.pwf", GetDataDir (), engine.GetMapName ());
|
return FormatBuffer ("%s%s.pwf", GetDataDir (isMemoryFile), engine.GetMapName ());
|
||||||
}
|
}
|
||||||
|
|
||||||
float Waypoint::GetTravelTime (float maxSpeed, const Vector &src, const Vector &origin)
|
float Waypoint::GetTravelTime (float maxSpeed, const Vector &src, const Vector &origin)
|
||||||
|
|
@ -2420,9 +2420,16 @@ void Waypoint::EraseFromHardDisk (void)
|
||||||
Init (); // reintialize points
|
Init (); // reintialize points
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Waypoint::GetDataDir (void)
|
const char *Waypoint::GetDataDir (bool isMemoryFile)
|
||||||
{
|
{
|
||||||
return FormatBuffer ("%s/addons/yapb/data/", engine.GetModName ());
|
static char buffer[256];
|
||||||
|
|
||||||
|
if (isMemoryFile)
|
||||||
|
sprintf (buffer, "addons/yapb/data/");
|
||||||
|
else
|
||||||
|
sprintf (buffer, "%s/addons/yapb/data/", engine.GetModName ());
|
||||||
|
|
||||||
|
return &buffer[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Waypoint::SetBombPosition (bool shouldReset)
|
void Waypoint::SetBombPosition (bool shouldReset)
|
||||||
|
|
@ -2625,7 +2632,7 @@ WaypointDownloadError Waypoint::RequestWaypoint (void)
|
||||||
recvPosition++;
|
recvPosition++;
|
||||||
}
|
}
|
||||||
|
|
||||||
File fp (waypoints.CheckSubfolderFile (), "wb");
|
File fp (waypoints.GetFileName (), "wb");
|
||||||
|
|
||||||
if (!fp.IsValid ())
|
if (!fp.IsValid ())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue