changed bot directory structure.

added folder renaming on start (temporary).
This commit is contained in:
jeefo 2015-06-25 22:56:42 +03:00
commit 0ff1caf5b9
3 changed files with 76 additions and 52 deletions

View file

@ -812,7 +812,7 @@ void InitConfig (void)
else
{
yb_communication_type.SetInt (1);
AddLogEntry (true, LL_DEFAULT, "Voice Communication disabled.");
AddLogEntry (true, LL_DEFAULT, "Chatter Communication disabled.");
}
// LOCALIZER INITITALIZATION
@ -909,7 +909,7 @@ void GameDLLInit (void)
RegisterCommand ("yb", CommandHandler);
// execute main config
ServerCommand ("exec addons/yapb/config/yapb.cfg");
ServerCommand ("exec addons/yapb/conf/yapb.cfg");
// register fake metamod command handler if we not! under mm
if (!g_isMetamod)
@ -2053,7 +2053,7 @@ void ServerActivate (edict_t *pentEdictList, int edictCount, int clientMax)
g_waypoint->Load ();
// execute main config
ServerCommand ("exec addons/yapb/config/yapb.cfg");
ServerCommand ("exec addons/yapb/conf/yapb.cfg");
if (TryFileOpen (FormatBuffer ("%s/maps/%s_yapb.cfg", GetModName (), GetMapName ())))
{
@ -2989,6 +2989,50 @@ export void Meta_Init (void)
g_isMetamod = true;
}
#include <io.h>
void FixDirectoryStructure (void)
{
// temporary function for 2.7 directory structure changes, will be delete after final releases of the bot
struct DirectoryTransition
{
String oldName;
String newName;
DirectoryTransition (void)
{
}
DirectoryTransition (const String &oldName, const String &newName)
{
String rootPath;
rootPath->AssignFormat ("%s/addons/yapb/", GetModName ());
this->oldName = rootPath + oldName;
this->newName = rootPath + newName;
}
void TryToRename (void)
{
if (access (oldName->GetBuffer (), 00) != -1)
rename (oldName->GetBuffer (), newName->GetBuffer ());
}
};
Array <DirectoryTransition> directories;
directories.Push (DirectoryTransition ("wptdefault", "data"));
directories.Push (DirectoryTransition ("data/data", "data/learned"));
directories.Push (DirectoryTransition ("config", "conf"));
directories.Push (DirectoryTransition ("conf/language", "conf/lang"));
IterateArray (directories, it)
directories[it].TryToRename ();
directories.RemoveAll ();
}
DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t *pGlobals)
{
// this is the very first function that is called in the game DLL by the engine. Its purpose
@ -3006,6 +3050,8 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
memcpy (&g_engfuncs, functionTable, sizeof (enginefuncs_t));
g_pGlobals = pGlobals;
FixDirectoryStructure ();
// register our cvars
g_convarWrapper->PushRegisteredConVarsToEngine ();

View file

@ -955,16 +955,16 @@ bool OpenConfig (const char *fileName, char *errorIfNotExists, File *outFile, bo
if (strcmp (fileName, "lang.cfg") == 0 && strcmp (yb_language.GetString (), "en") == 0)
return false;
const char *languageDependantConfigFile = FormatBuffer ("%s/addons/yapb/config/language/%s_%s", GetModName (), yb_language.GetString (), fileName);
const char *languageDependantConfigFile = FormatBuffer ("%s/addons/yapb/conf/lang/%s_%s", GetModName (), yb_language.GetString (), fileName);
// check is file is exists for this language
if (TryFileOpen (languageDependantConfigFile))
outFile->Open (languageDependantConfigFile, "rt");
else
outFile->Open (FormatBuffer ("%s/addons/yapb/config/language/en_%s", GetModName (), fileName), "rt");
outFile->Open (FormatBuffer ("%s/addons/yapb/conf/lang/en_%s", GetModName (), fileName), "rt");
}
else
outFile->Open (FormatBuffer ("%s/addons/yapb/config/%s", GetModName (), fileName), "rt");
outFile->Open (FormatBuffer ("%s/addons/yapb/conf/%s", GetModName (), fileName), "rt");
if (!outFile->IsValid ())
{
@ -976,7 +976,7 @@ bool OpenConfig (const char *fileName, char *errorIfNotExists, File *outFile, bo
const char *GetWaypointDir (void)
{
return FormatBuffer ("%s/addons/yapb/wptdefault/", GetModName ());
return FormatBuffer ("%s/addons/yapb/data/", GetModName ());
}
void RegisterCommand (char *command, void funcPtr (void))
@ -1059,42 +1059,20 @@ void CheckWelcomeMessage (void)
void DetectCSVersion (void)
{
byte *detection = NULL;
const char *const infoBuffer = "Game Registered: CS %s (0x%d)";
// switch version returned by dll loader
switch (g_gameVersion)
{
// counter-strike 1.x, WON ofcourse
case CSV_OLD:
ServerPrint (infoBuffer, "1.x (WON)", sizeof (Bot));
break;
if (g_gameVersion == CSV_OLD || g_gameVersion == CSV_CZERO)
return;
// counter-strike 1.6 or higher (plus detects for non-steam versions of 1.5)
case CSV_STEAM:
detection = (*g_engfuncs.pfnLoadFileForMe) ("events/galil.sc", NULL);
byte *detection = (*g_engfuncs.pfnLoadFileForMe) ("events/galil.sc", NULL);
if (detection != NULL)
{
ServerPrint (infoBuffer, "1.6 (Steam)", sizeof (Bot));
g_gameVersion = CSV_STEAM; // just to be sure
}
else if (detection == NULL)
{
ServerPrint (infoBuffer, " <= 1.5 (WON)", sizeof (Bot));
g_gameVersion = CSV_OLD; // reset it to WON
}
if (detection != NULL)
g_gameVersion = CSV_STEAM; // just to be sure
else if (detection == NULL)
g_gameVersion = CSV_OLD; // reset it to WON
// if we have loaded the file free it
if (detection != NULL)
(*g_engfuncs.pfnFreeFile) (detection);
break;
// counter-strike cz
case CSV_CZERO:
ServerPrint (infoBuffer, "CZ (Steam)", sizeof (Bot));
break;
}
// if we have loaded the file free it
if (detection != NULL)
(*g_engfuncs.pfnFreeFile) (detection);
}
void PlaySound (edict_t *ent, const char *name)

View file

@ -862,7 +862,7 @@ void Waypoint::SaveExperienceTab (void)
}
}
int result = Compressor::Compress (FormatBuffer ("%sdata/%s.exp", GetWaypointDir (), GetMapName ()), (unsigned char *)&header, sizeof (ExtensionHeader), (unsigned char *)experienceSave, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
int result = Compressor::Compress (FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), GetMapName ()), (unsigned char *)&header, sizeof (ExtensionHeader), (unsigned char *)experienceSave, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
delete [] experienceSave;
@ -902,7 +902,7 @@ void Waypoint::InitExperienceTab (void)
(g_experienceData + (i * g_numWaypoints) + j)->team1Value = 0;
}
}
File fp (FormatBuffer ("%sdata/%s.exp", GetWaypointDir (), GetMapName ()), "rb");
File fp (FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), GetMapName ()), "rb");
// if file exists, read the experience data from it
if (fp.IsValid ())
@ -916,7 +916,7 @@ void Waypoint::InitExperienceTab (void)
{
ExperienceSave *experienceLoad = new ExperienceSave[g_numWaypoints * g_numWaypoints];
Compressor::Uncompress (FormatBuffer ("%sdata/%s.exp", GetWaypointDir (), GetMapName ()), sizeof (ExtensionHeader), (unsigned char *)experienceLoad, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
Compressor::Uncompress (FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), GetMapName ()), sizeof (ExtensionHeader), (unsigned char *)experienceLoad, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
for (i = 0; i < g_numWaypoints; i++)
{
@ -968,7 +968,7 @@ void Waypoint::SaveVisibilityTab (void)
header.fileVersion = FV_VISTABLE;
header.pointNumber = g_numWaypoints;
File fp (FormatBuffer ("%sdata/%s.vis", GetWaypointDir (), GetMapName ()), "wb");
File fp (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()), "wb");
if (!fp.IsValid ())
{
@ -977,7 +977,7 @@ void Waypoint::SaveVisibilityTab (void)
}
fp.Close ();
Compressor::Compress (FormatBuffer ("%sdata/%s.vis", GetWaypointDir (), GetMapName ()), (unsigned char *) &header, sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (byte));
Compressor::Compress (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()), (unsigned char *) &header, sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (byte));
}
void Waypoint::InitVisibilityTab (void)
@ -987,7 +987,7 @@ void Waypoint::InitVisibilityTab (void)
ExtensionHeader header;
File fp (FormatBuffer ("%sdata/%s.vis", GetWaypointDir (), GetMapName ()), "rb");
File fp (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()), "rb");
m_redoneVisibility = false;
if (!fp.IsValid ())
@ -1012,7 +1012,7 @@ void Waypoint::InitVisibilityTab (void)
return;
}
int result = Compressor::Uncompress (FormatBuffer ("%sdata/%s.vis", GetWaypointDir (), GetMapName ()), sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (byte));
int result = Compressor::Uncompress (FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()), sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (byte));
if (result == -1)
{
@ -2092,7 +2092,7 @@ void Waypoint::InitPathMatrix (void)
void Waypoint::SavePathMatrix (void)
{
File fp (FormatBuffer ("%sdata/%s.pmt", GetWaypointDir (), GetMapName ()), "wb");
File fp (FormatBuffer ("%slearned/%s.pmt", GetWaypointDir (), GetMapName ()), "wb");
// unable to open file
if (!fp.IsValid ())
@ -2114,7 +2114,7 @@ void Waypoint::SavePathMatrix (void)
bool Waypoint::LoadPathMatrix (void)
{
File fp (FormatBuffer ("%sdata/%s.pmt", GetWaypointDir (), GetMapName ()), "rb");
File fp (FormatBuffer ("%slearned/%s.pmt", GetWaypointDir (), GetMapName ()), "rb");
// file doesn't exists return false
if (!fp.IsValid ())
@ -2364,10 +2364,10 @@ void Waypoint::EraseFromHardDisk (void)
// if we're delete waypoint, delete all corresponding to it files
deleteList[0] = FormatBuffer ("%s%s.pwf", GetWaypointDir (), GetMapName ()); // waypoint itself
deleteList[1] = FormatBuffer ("%sdata/%s.exp", GetWaypointDir (), GetMapName ()); // corresponding to waypoint experience
deleteList[3] = FormatBuffer ("%sdata/%s.vis", GetWaypointDir (), GetMapName ()); // corresponding to waypoint vistable
deleteList[3] = FormatBuffer ("%sdata/%s.pmt", GetWaypointDir (), GetMapName ()); // corresponding to waypoint path matrix
deleteList[4] = FormatBuffer ("%sdata/%s.xml", GetWaypointDir (), GetMapName ()); // corresponding to waypoint xml database
deleteList[1] = FormatBuffer ("%slearned/%s.exp", GetWaypointDir (), GetMapName ()); // corresponding to waypoint experience
deleteList[3] = FormatBuffer ("%slearned/%s.vis", GetWaypointDir (), GetMapName ()); // corresponding to waypoint vistable
deleteList[3] = FormatBuffer ("%slearned/%s.pmt", GetWaypointDir (), GetMapName ()); // corresponding to waypoint path matrix
deleteList[4] = FormatBuffer ("%slearned/%s.xml", GetWaypointDir (), GetMapName ()); // corresponding to waypoint xml database
for (int i = 0; i < 4; i++)
{