mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-29 09:29:10 +00:00
(svn r26487) -Codechange: use lastof instead of lengthof/sizeof for script names
This commit is contained in:
@@ -48,9 +48,9 @@ AIScannerInfo::~AIScannerInfo()
|
||||
delete this->info_dummy;
|
||||
}
|
||||
|
||||
void AIScannerInfo::GetScriptName(ScriptInfo *info, char *name, int len)
|
||||
void AIScannerInfo::GetScriptName(ScriptInfo *info, char *name, const char *last)
|
||||
{
|
||||
snprintf(name, len, "%s", info->GetName());
|
||||
seprintf(name, last, "%s", info->GetName());
|
||||
}
|
||||
|
||||
void AIScannerInfo::RegisterAPI(class Squirrel *engine)
|
||||
@@ -145,10 +145,10 @@ void AIScannerLibrary::Initialize()
|
||||
ScriptScanner::Initialize("AIScanner");
|
||||
}
|
||||
|
||||
void AIScannerLibrary::GetScriptName(ScriptInfo *info, char *name, int len)
|
||||
void AIScannerLibrary::GetScriptName(ScriptInfo *info, char *name, const char *last)
|
||||
{
|
||||
AILibrary *library = static_cast<AILibrary *>(info);
|
||||
snprintf(name, len, "%s.%s", library->GetCategory(), library->GetInstanceName());
|
||||
seprintf(name, last, "%s.%s", library->GetCategory(), library->GetInstanceName());
|
||||
}
|
||||
|
||||
void AIScannerLibrary::RegisterAPI(class Squirrel *engine)
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
void SetDummyAI(class AIInfo *info);
|
||||
|
||||
protected:
|
||||
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, int len);
|
||||
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
|
||||
/* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; }
|
||||
/* virtual */ Subdirectory GetDirectory() const { return AI_DIR; }
|
||||
/* virtual */ const char *GetScannerName() const { return "AIs"; }
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
class AILibrary *FindLibrary(const char *library, int version);
|
||||
|
||||
protected:
|
||||
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, int len);
|
||||
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
|
||||
/* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; }
|
||||
/* virtual */ Subdirectory GetDirectory() const { return AI_LIBRARY_DIR; }
|
||||
/* virtual */ const char *GetScannerName() const { return "AI Libraries"; }
|
||||
|
@@ -23,9 +23,9 @@ void GameScannerInfo::Initialize()
|
||||
ScriptScanner::Initialize("GSScanner");
|
||||
}
|
||||
|
||||
void GameScannerInfo::GetScriptName(ScriptInfo *info, char *name, int len)
|
||||
void GameScannerInfo::GetScriptName(ScriptInfo *info, char *name, const char *last)
|
||||
{
|
||||
snprintf(name, len, "%s", info->GetName());
|
||||
seprintf(name, last, "%s", info->GetName());
|
||||
}
|
||||
|
||||
void GameScannerInfo::RegisterAPI(class Squirrel *engine)
|
||||
@@ -86,10 +86,10 @@ void GameScannerLibrary::Initialize()
|
||||
ScriptScanner::Initialize("GSScanner");
|
||||
}
|
||||
|
||||
void GameScannerLibrary::GetScriptName(ScriptInfo *info, char *name, int len)
|
||||
void GameScannerLibrary::GetScriptName(ScriptInfo *info, char *name, const char *last)
|
||||
{
|
||||
GameLibrary *library = static_cast<GameLibrary *>(info);
|
||||
snprintf(name, len, "%s.%s", library->GetCategory(), library->GetInstanceName());
|
||||
seprintf(name, last, "%s.%s", library->GetCategory(), library->GetInstanceName());
|
||||
}
|
||||
|
||||
void GameScannerLibrary::RegisterAPI(class Squirrel *engine)
|
||||
|
@@ -28,7 +28,7 @@ public:
|
||||
class GameInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match);
|
||||
|
||||
protected:
|
||||
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, int len);
|
||||
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
|
||||
/* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; }
|
||||
/* virtual */ Subdirectory GetDirectory() const { return GAME_DIR; }
|
||||
/* virtual */ const char *GetScannerName() const { return "Game Scripts"; }
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
class GameLibrary *FindLibrary(const char *library, int version);
|
||||
|
||||
protected:
|
||||
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, int len);
|
||||
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
|
||||
/* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; }
|
||||
/* virtual */ Subdirectory GetDirectory() const { return GAME_LIBRARY_DIR; }
|
||||
/* virtual */ const char *GetScannerName() const { return "GS Libraries"; }
|
||||
|
@@ -110,7 +110,7 @@ void ScriptScanner::Reset()
|
||||
void ScriptScanner::RegisterScript(ScriptInfo *info)
|
||||
{
|
||||
char script_original_name[1024];
|
||||
this->GetScriptName(info, script_original_name, sizeof(script_original_name));
|
||||
this->GetScriptName(info, script_original_name, lastof(script_original_name));
|
||||
strtolower(script_original_name);
|
||||
|
||||
char script_name[1024];
|
||||
|
@@ -101,7 +101,7 @@ protected:
|
||||
/**
|
||||
* Get the script name how to store the script in memory.
|
||||
*/
|
||||
virtual void GetScriptName(ScriptInfo *info, char *name, int len) = 0;
|
||||
virtual void GetScriptName(ScriptInfo *info, char *name, const char *last) = 0;
|
||||
|
||||
/**
|
||||
* Get the filename to scan for this type of script.
|
||||
|
Reference in New Issue
Block a user