diff options
author | rubidium <rubidium@openttd.org> | 2014-04-23 21:16:58 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2014-04-23 21:16:58 +0000 |
commit | a5274117bdc323aedc95dbecea6014a308b9a9a0 (patch) | |
tree | 65c485894dbc677cfbc5473f549312498435249b /src | |
parent | 5b82822c12e014771dceaf9d909e1c0f3653c5a9 (diff) | |
download | openttd-a5274117bdc323aedc95dbecea6014a308b9a9a0.tar.xz |
(svn r26487) -Codechange: use lastof instead of lengthof/sizeof for script names
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/ai_scanner.cpp | 8 | ||||
-rw-r--r-- | src/ai/ai_scanner.hpp | 4 | ||||
-rw-r--r-- | src/game/game_scanner.cpp | 8 | ||||
-rw-r--r-- | src/game/game_scanner.hpp | 4 | ||||
-rw-r--r-- | src/script/script_scanner.cpp | 2 | ||||
-rw-r--r-- | src/script/script_scanner.hpp | 2 |
6 files changed, 14 insertions, 14 deletions
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp index ad66f03c6..2d7ab4119 100644 --- a/src/ai/ai_scanner.cpp +++ b/src/ai/ai_scanner.cpp @@ -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) diff --git a/src/ai/ai_scanner.hpp b/src/ai/ai_scanner.hpp index e09eca9d9..d8e8a6993 100644 --- a/src/ai/ai_scanner.hpp +++ b/src/ai/ai_scanner.hpp @@ -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"; } diff --git a/src/game/game_scanner.cpp b/src/game/game_scanner.cpp index a251f3386..bc02f6afd 100644 --- a/src/game/game_scanner.cpp +++ b/src/game/game_scanner.cpp @@ -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) diff --git a/src/game/game_scanner.hpp b/src/game/game_scanner.hpp index f1d334f0f..071d19d38 100644 --- a/src/game/game_scanner.hpp +++ b/src/game/game_scanner.hpp @@ -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"; } diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp index 578068592..2eb056049 100644 --- a/src/script/script_scanner.cpp +++ b/src/script/script_scanner.cpp @@ -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]; diff --git a/src/script/script_scanner.hpp b/src/script/script_scanner.hpp index 792d36bae..5418dbd85 100644 --- a/src/script/script_scanner.hpp +++ b/src/script/script_scanner.hpp @@ -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. |