mirror of https://github.com/OpenTTD/OpenTTD
Codefix: Avoid type-casting function pointer with incorrect type. (#12929)
Make `AutolengthProc` take `int` instead of `void *`, avoiding pointer parameters.pull/12836/head
parent
9631c68ce6
commit
7f5a3eaf83
|
@ -41,9 +41,9 @@ static const SaveLoad _ai_running_desc[] = {
|
|||
SLEG_CONDVAR("running_version", _ai_saveload_version, SLE_UINT32, SLV_AI_LOCAL_CONFIG, SL_MAX_VERSION),
|
||||
};
|
||||
|
||||
static void SaveReal_AIPL(int *index_ptr)
|
||||
static void SaveReal_AIPL(int arg)
|
||||
{
|
||||
CompanyID index = (CompanyID)*index_ptr;
|
||||
CompanyID index = static_cast<CompanyID>(arg);
|
||||
AIConfig *config = AIConfig::GetConfig(index, AIConfig::SSS_FORCE_GAME);
|
||||
|
||||
if (config->HasScript()) {
|
||||
|
@ -162,7 +162,7 @@ struct AIPLChunkHandler : ChunkHandler {
|
|||
|
||||
for (int i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
||||
SlSetArrayIndex(i);
|
||||
SlAutolength((AutolengthProc *)SaveReal_AIPL, &i);
|
||||
SlAutolength(SaveReal_AIPL, i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@ static const SaveLoad _game_script_desc[] = {
|
|||
SLEG_VAR("version", _game_saveload_version, SLE_UINT32),
|
||||
};
|
||||
|
||||
static void SaveReal_GSDT(int *)
|
||||
static void SaveReal_GSDT(int)
|
||||
{
|
||||
GameConfig *config = GameConfig::GetConfig();
|
||||
|
||||
|
@ -109,7 +109,7 @@ struct GSDTChunkHandler : ChunkHandler {
|
|||
{
|
||||
SlTableHeader(_game_script_desc);
|
||||
SlSetArrayIndex(0);
|
||||
SlAutolength((AutolengthProc *)SaveReal_GSDT, nullptr);
|
||||
SlAutolength(SaveReal_GSDT, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1925,7 +1925,7 @@ void SlGlobList(const SaveLoadTable &slt)
|
|||
* @param proc The callback procedure that is called
|
||||
* @param arg The variable that will be used for the callback procedure
|
||||
*/
|
||||
void SlAutolength(AutolengthProc *proc, void *arg)
|
||||
void SlAutolength(AutolengthProc *proc, int arg)
|
||||
{
|
||||
assert(_sl.action == SLA_SAVE);
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ void DoAutoOrNetsave(FiosNumberedSaveName &counter);
|
|||
SaveOrLoadResult SaveWithFilter(std::shared_ptr<struct SaveFilter> writer, bool threaded);
|
||||
SaveOrLoadResult LoadWithFilter(std::shared_ptr<struct LoadFilter> reader);
|
||||
|
||||
typedef void AutolengthProc(void *arg);
|
||||
typedef void AutolengthProc(int);
|
||||
|
||||
/** Type of a chunk. */
|
||||
enum ChunkType {
|
||||
|
@ -1290,7 +1290,7 @@ int SlIterateArray();
|
|||
void SlSetStructListLength(size_t length);
|
||||
size_t SlGetStructListLength(size_t limit);
|
||||
|
||||
void SlAutolength(AutolengthProc *proc, void *arg);
|
||||
void SlAutolength(AutolengthProc *proc, int arg);
|
||||
size_t SlGetFieldLength();
|
||||
void SlSetLength(size_t length);
|
||||
size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld);
|
||||
|
|
Loading…
Reference in New Issue